Readonly
constructorContains the rpcs used to create instances.
Readonly
constructorsOverview of the available Constructors in the network.
M.Karkowski
INopeInstanceManager
Readonly
instancesOverview of the available instances in the network.
OriginalKey
= DispatcherID (string);
OriginalValue
= Available Instance Messages (IAvailableInstancesMsg);
ExtractedKey
= The name of the Instance (string);
ExtractedValue
= instance-description (INopeModuleDescription);
M.Karkowski
INopeInstanceManager
Readonly
internalContains the identifiers of the instances, which are hosted in the provided dispatcher.
M.Karkowski
INopeInstanceManager
Readonly
readyFlag to indicate, that the system is ready.
M.Karkowski
INopeInstanceManager
Allows to create an instance. This might be the case on remote dispatchers or
on the same element. Only a wrapper is returned, which communicates with a
dispatcher, because we dont know where the element is provided. To know which
instanceManager
hosts the instance can use the INopeInstanceManager.getDispatcherForInstance method.
The returned wrapper
behaves like a normal "internal" class. If this method
is called, a {@link IGenericNopeModule}
is returned as type by default. If a
special wrapper is required for a type, such wrappers can be defined and customized
via registerInternalWrapperGenerator and unregisterInternalWrapperGenerator.
Here, too, the type is decisive. *
If there are multiple INopeInstanceManager able to create an instance,
the selector
is used to select a dispatcher
and its instanceManger, to create
the instance.
If the instances already exists and the type is matching, the assignmentValid
callback
is used, to test if the required assignmet could be valid. E.g. you require the instance
to be hosted on a specific host. The assignmentValid
will check if the assignment is valid.
// Create an Instance:
const instance = await manager.createInstance<TestModule>({
identifier: "instance", // <- Must be provided
type: "TestModule", // <- Must be provided and present in the Network
params: ["p1", "p2"], // <- Optional. The Parameters, required by the class to initialize see {@link INopeModule.init}
});
M.Karkowski
INopeInstanceManager
The Type of the Return type.
Description requrired to create the Message (see IInstanceCreationMsg).
The properties type
and identifier
must be provided.
Optional
options: { Additional Options used during creating the Instance
Optional
assignmentIf the instances already exists and the type is matching, the assignmentValid
callback
is used, to test if the required assignmet could be valid. E.g. you require the instance
to be hosted on a specific host. The assignmentValid
will check if the assignment is valid.
Optional
linkFlag to link the events. Defaults to true. Should not be touched. can be used, if e.g. only methods of an instance are relevant.
Optional
linkFlag to link the properties. Defaults to true. Should not be touched. can be used, if e.g. only methods of an instance are relevant.
Optional
selector?: ValidSelectorFunctionIf there are multiple INopeInstanceManager able to create an instance,
the selector
is used to select a dispatcher
and its instanceManger, to create
the instance.
Disposes an instance and removes it. Thereby the Instance wont be available for other InstanceManagers in the system.
M.Karkowski
INopeInstanceManager
The Instance to consider
Manual function, used to generate a Wrapper. This should only be called, when instances are registerd with NopeInstanceManager.registerInstance is used and you are shure, that the instance is created manually. Please allways prefer to use NopeInstanceManager.createInstance
Returns the instance Description for a specific instance. It is just a simplified wrapper for the "instances"-property.
M.Karkowski
INopeInstanceManager
The identifier for instance (its name)
Creates Wrappers for the Type of the given element.
Returns the hosting dispatcher for the given instance.
M.Karkowski
The Status or false if not present.
INopeInstanceManager
The identifier for instance (its name)
Registers a Constructor, that enables other NopeInstanceManagers to create an instance of the given type. Therefore a callback "cb" is registered with the given "typeIdentifier".
The function allways need as callback which must return a INopeModule (or an extension of it)
// Now we register the constructor with the type 'TestModule'
await manager.registerConstructor(
"TestModule",
async (core, identifier) => {
assert(
identifier === "instance",
"The identifier has not been transmitted"
);
return new TestModule(core);
}
);
M.Karkowski
INopeInstanceManager
The identifier for the Constructor (Like a service)
The callback used, to create an instance.
Option, to statically register an instance, without using an specific generator etc. This instance is just present in the network.
M.Karkowski
INopeInstanceManager
The Instance to consider
Defaultly a generic wrapper will be returned, when an instance is created. you can specifiy specific wrapper type for different "typeIdentifier" with this method.
M.Karkowski
INopeInstanceManager
The identifier for the Constructor (Like a service)
The Callback which creates the specific wrapper.
Description of an Instance-Manager
Unregisters a present Constructor. After this, created instances are still valid, the user isnt able to create new ones.
M.Karkowski
INopeInstanceManager
The identifier for the Constructor (Like a service)
Generated using TypeDoc
A Manager, which is capable of creating instance on different Managers in the Network.
It is defaultly implemented by NopeInstanceManager
The
instanceManager
is used to create, remove and get access to instances. the approach is based on the object oriented method. I.e. there are the following elements:NoPE
by an ID / atype
.NoPE
as a service (service name includes the identifier, among other things).NoPE
by identifier (herestrings
)The manager keeps track of the available instances in the network and allows to create
wrappers
for these instances. This allows to simplify and unify the access for the user of instances running in a different runtime. To make this possible it uses the following elements:connectivityManager
: see above. Used to identify new and dead dispatchers.dispatcher
is identified, standardized descriptions of all hosted instances are sent.dispatcher
is identified as dead, thewrappers
are deleted or removed.: see above. Used here to distribute
constructorsof classes and
destructors` of instances on the network. I.e.:constructors
of the classes anddestructors
of the instances follow a defined naming convention, so that they can be identified by theinstanceManager
. TheInstanceManger
can be interacted with using the following methods and properties:getInstancesOfType
: returns all available instances of a given type.instanceExists
: tests if an instance with the given identifier exists.getInstanceDescription
: Returns the standardized description of an instance. This information is also shared with allinstanceManagers
on the network.registerInstance
: Allows to manually register an instance.deleteInstance
: Allows the manual removal of an instance.registerConstructor
: Registers a constructor. Among other things, it is possible to specify the number of instances that may be created on theinstanceManager
. If more than onedispatcher
is able to create an instance with the given type, then - as withrpcManger
- the selection follows via a so-called selector.unregisterConstructor
: Removes a constructor.constructorExists
: Tests if a constructor is known for a type.createInstance
: Allows the creation of an instance. This may be the case for remote dispatchers or for the same element. Only a wrapper communicating with a dispatcher is returned, since we do not know where the element is provided. To know whichinstanceManager
hosts the instance can use thegetDispatcherForInstance
method. The returnedwrapper
behaves like a normal "internal" class. If this method is called, aGenericModule
is returned as type by default. If a special wrapper is required for a type, such wrappers can be defined and customized viaregisterInternalWrapperGenerator
andunregisterInternalWrapperGenerator
. Here, too, the type is decisive.Example
Author
M.Karkowski
Export
INopeInstanceManager