Base service implementation
- EndpointsMixin
- endpoints
- ServiceConfig
- merge
- defineServiceConsumerProperties
- ServiceLogger
- ServiceProviderMixin
- Service
- StandaloneServiceProvider
Endpoint accessor mixin. Manages endpoints in a container.
-
superclass
Default set of endpoints to create.
Returns Object {} empty set
Extends Service
Config providing service. Dispatches config requests to services. Also preserves them until a maching service becomes avaliable.
Deliver configuration for a given service.
Forget about preserved config of a service.
-
name
string service name
Set config entry.
-
key
string path to the value -
value
any
We always start immediate.
Returns boolean true
Returns string 'config'
Merge from b into a. When a and b are arrays of values only the none duplicates are appendend to a.
-
a
any -
b
any
Returns any merged b into a
Assign services based on a configuration.
-
target
Object object -
config
Object service defintion -
provider
Object service provider -
waitUntilFactoryPresent
boolean
Extends Service
Log receiving service.
We always start immediate.
Returns boolean true
Returns string 'logger'
Adds a log input endpoint to the set of Service endpoints.
Returns Object predefined endpoints
Provide services and hold service configuration. By default a service provider has two build in services 'logger' and 'config'.
-
superclass
-
serviceLoggerClass
(optional, defaultServiceLogger
) -
serviceConfigClass
(optional, defaultServiceConfig
)
Extends EndpointsMixin(StateTransitionMixin(LogLevelMixin(class {}), prepareActions({ start: { stopped: rsfDefault }, restart: { stopped: rsfDefault, running: { target: "running", during: "restarting", timeout } }, stop: { running: ssfDefault, starting: ssfDefault, failed: ssfDefault } }), "stopped"))
Service The initial state is 'stopped'. All services have at least three endpoints:
- log out: log events
- config in: configuration request
- command in: administrative actions to be executed by the step
-
config
Object -
ic
InitializationContext
-
endpoints
Object
Used in human readable state messages. Besides the actual service name it may contain additional short hints.
Returns string
Called when the service state changes. Emits a serviceStateChanged event to the owner.
Called when state transition is not allowed.
-
action
string originating action name
- Throws any always
Deliver transition timeout.
-
transition
Object
Returns number milliseconds before throwing for a long running transition
Opens all endpoint connections.
Closes all endpoint connections.
Restart action. default implementation does a _stop() and a _start()
Returns Promise fulfills after start
Restarts if in running mode. Otherwise does nothing.
Returns Promise resolves when restart is done (or immediate if no restart triggered)
Mapping of properties used in toString.
Returns Object
Base service is not a provider.
Returns boolean false
Returns the string representation of this service.
Returns string human readable name
Deliver json representation.
-
options
Object-
options.includeRuntimeInfo
boolean include runtime informtion like state -
options.includeDefaults
boolean include default endpoints -
options.includeName
boolean include name of the service -
options.includeConfig
boolean include config attributes -
options.includePrivate
boolean include private config attributes
-
Returns Object json representation
Defaults to the type.
Returns string type
Should we start when beeing registered.
Returns boolean false
Takes attribute values from config parameters and copies them over to the object. Copying is done according to configurationAttributes. Which means we loop over all configuration attributes. and then for each attribute decide if we use the default, call a setter function or simply assign the attribute value.
-
config
Object
Returns Set of modified attributes
Use new configuration. Internally calls _configure(config) as the constructor does. If attribute with needsRestart are touched the restartIfRunning method will be called.
-
config
Object
Returns Promise fillfills when config is applied
Adds service name to the log event.
Meta information for the config attributes.
- default optional default value of the attribute
- needsRestart optional modification requires a service restart
- setter(newValue,attribute) optional function to be used if simple value assignment is not enough The Service class only defines the logLevel, and start/stop/restart timeout attribute
Returns Object
Definition of the predefined endpoints.
- log out
- config in
Returns Object predefined endpoints
Extends ServiceProviderMixin(Service)
Simple service manager (for examples and testing only).
Returns string 'standalone-provider'
With npm do:
npm install @kronos-integration/service
BSD-2-Clause