kronos-service v4.17.2
kronos-service
Base service implementation
API
Table of Contents
- DESCRIPTION
- Service
- ServiceLogger
- ServiceConfig
- defineServiceConsumerProperties
- ServiceProviderMixin
- InterceptorProviderMixin
- EndpointsMixin
- endpoints
DESCRIPTION
key of the service description
Service
Extends EndpointsMixin(StateTransitionMixin(LogLevelMixin(events), prepareActions({ start: { stopped: { target: 'running', during: 'starting', rejected: 'failed', timeout: 5000 } }, restart: { stopped: { target: 'running', during: 'starting', rejected: 'failed', timeout: 5000 }, running: { target: 'running', during: 'restarting', timeout: 5000 } }, stop: { running: { target: 'stopped', during: 'stopping', rejected: 'failed', timeout: 5000 }, starting: { target: 'stopped', during: 'stopping', rejected: 'failed', timeout: 5000 }, failed: { target: 'stopped', during: 'stopping', rejected: 'failed', timeout: 1000 } } }), '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
Parameters
stateChanged
Called when the service state changes. Emits a serviceStateChanged event to the owner
Parameters
rejectWrongState
Called when state transition is not allowed
Parameters
actionstring originating action name
- Throws any always
timeoutForTransition
Deliver transtion timeout
Parameters
transitionObject
Returns number milliseconds before throwing for a logn running transition
_restart
Restart action default implementation does a _stop() and a _start()
Returns Promise fulfills after start
restartIfRunning
Restarts if in running mode Otherwise does nothing
Returns Promise resolves when restart is done (or immediate if no restart triggered)
toString
Returns the string representation of this step
Returns string human readable name
toJSONWithOptions
Deliver json representation
Parameters
optionsObject (optional, default{})
Returns Object json representation
name
defaults to the type
Returns string type
autostart
Should we start when beeing registered
Returns boolean false
_configure
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
Parameters
configObject
Returns Set of modified attributes
configure
Use new configuration. Internally calls _configure(config) as the constructor does If attribute with needsRestart are touched the restartIfRunning method will be called
Parameters
configObject
Returns Promise fillfills when config is applied
log
Adds service name to the log event
Parameters
endpointParentSeparator
Returns string separator between service name and endpoint name
configurationAttributes
Meta information for the config attributes.
- default optional default value of the attribute
- needsRestart optional modification requires a service restart
- setter(newValue,attrribute) optional function to be used if simple value assignment is not enough The Service class only defines the logLevel, ans start timeout attribute
Returns Object
endpoints
Definition of the predefined endpoints
- log out
- config in
- command in
Returns Object predefined endpoints
ServiceLogger
Extends Service
Log receiving service
Parameters
configowner
autostart
We always start immediate
Returns boolean true
name
Returns string 'logger'
endpoints
Adds a log input endpoint to the set of Service endpoints
Returns Object predefined endpoints
ServiceConfig
Extends Service
Config providing service Dispatches config requests to services or preserves them until a maching service becomes avaliable
Parameters
configowner
autostart
We always start immediate
Returns boolean true
name
Returns string 'config'
defineServiceConsumerProperties
assign services based on a configuration
Parameters
targetObject objectconfigObject service defintionproviderObject service providerwaitUntilFactoryPresentboolean
ServiceProviderMixin
Provide services and hold service configuration. By default a service provider has two build in services 'logger' and 'config'.
Parameters
superclass
InterceptorProviderMixin
Register & provide Interceptors.
Parameters
superclass
EndpointsMixin
Endpoint accessor mixin Manages endpoints in a container
Parameters
superclassClass class to be extended
Returns Class extended class
endpoints
default set of endpoints to create
Returns Object {} empty set
install
With npm do:
npm install kronos-servicelicense
BSD-2-Clause
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
