LCMicroServiceDelegate
@protocol LCMicroServiceDelegate <NSObject>
An LCMicroService
may have an optional delegate to listen for events on start,
exit and error conditions.
-
Optional listener for when the
LCMicroService
has successfully started.Listens for when the
LCMicroService
has been inititialized and the environment is ready to receive event listeners. This is called after the Node.js environment has been set up, but before the micro service JavaScript code has been executed. It is safe to add any event listeners here, but emitted events will not be seen by the JavaScript service until its code has been run. The JavaScript code should emit an event to let the host know that it is ready to receive events.Declaration
Objective-C
- (void)onStart:(LCMicroService *)service synchronizer:(LCSynchronizer *_Nullable)synchronizer;
Swift
optional func onStart(_ service: LCMicroService!, synchronizer: LCSynchronizer?)
Parameters
service
The micro service which has now started.
synchronizer
Used to synchronize asynchronous init. Ignore if you have no async initialization. Can be
nil
if the process cannot be managed asynchronously, so check first. -
Optional listener for when the
LCMicroService
has successfully exited.Listens for when the
LCMicroService
has exited gracefully. TheLCMicroService
is no longer available and is shutting down.Called immediately before the
LCMicroService
exits. This is a graceful exit, and is mutually exclusive with the-onError:exception:
method. Only one of either the exit listener or error listener will be called from anyLCMicroService
.Declaration
Objective-C
- (void)onExit:(LCMicroService *)service exitCode:(int)exitCode;
Swift
optional func onExit(_ service: LCMicroService!, exitCode: Int32)
Parameters
service
The micro service which is now exiting.
exitCode
The exit code emitted by the Node.js process.
-
Optional listener for when the
LCMicroService
has exited unexpectedly.Listens for any errors that may cause the
LCMicroService
to shut down unexpectedly. TheLCMicroService
is no longer available and may have already crashed.Called upon an exception state. This is an unexpected exit, and is mutually exclusive with the
-onExit:exitCode:
method. Only one of either the exit listener or error listener will be called from any MicroService.Declaration
Objective-C
- (void)onError:(LCMicroService *)service exception:(NSException *)exception;
Swift
optional func onError(_ service: LCMicroService!, exception: Any!)
Parameters
service
The micro service which failed.
exception
The thrown error.