Reference Source
import DistributedInstance from 'devapt-core-common/js/base/distributed_instance.js'
public class | source

DistributedInstance

Extends:

LoggableErrorableSettingsableStateableInstance → DistributedInstance

Direct Subclass:

TopologyDeployItem

Indirect Subclass:

TopologyDeployLocalNode

Distributed instances base class: enable communication inside a node or between nodes.

Example:

API:
		->load():nothing
	    ->load_topology_settings(arg_settings):nothing

		->send(DistributedMessage|DistributedMetrics|DistributedLogs):boolean

     ->enable_on_bus(arg_bus):nothing
     ->disable_on_bus(arg_bus):nothing

API for messages:
		->send_msg(target, payload):boolean
		->receive_msg(DistributedMessage):nothing
		->enable_msg():nothing
		->disable_msg():nothing

API for metrics:
		->send_metrics(type, values):boolean
		->receive_metrics(DistributedMetrics):nothing
		->enable_metrics():nothing
		->disable_metrics():nothing

API for logs:
		->send_logs(ts, level, texts):boolean
		->receive_logs(DistributedLogs):nothing
		->enable_logs():nothing
		->disable_logs():nothing

Constructor Summary

Public Constructor
public

constructor(arg_collection: string, arg_name: string, arg_class: string, arg_settings: object, arg_log_context: string): nothing

Create a DistributedInstance.

Member Summary

Public Members
public

Class type flag.

Private Members
private

Bus unsubscribes handlers map.

private

Logs messages bus instance.

private

Metrics messages bus instance.

private

Messages bus instance.

Method Summary

Public Methods
public

disable_logs(): nothing

Disable distributed logs.

public

disable_metrics(): nothing

Disable distributed metrics.

public

disable_msg(): nothing

Disable distributed messaging.

public

disable_on_bus(arg_bus: MessageBus, arg_channel: string): nothing

Disable distributed messaging.

public

enable_logs(): nothing

Enable distributed logs.

public

enable_metrics(): nothing

Enable distributed metrics.

public

enable_msg(): nothing

Enable distributed messaging.

public

enable_on_bus(arg_bus: MessageBus, arg_channel: string, arg_method: string, arg_alias: string): nothing

Enable distributed messaging.

public

load(): nothing

Load instance settings.

public

load_topology_settings(arg_settings: object): nothing

Load topology settings.

public

receive_logs(arg_msg: DistributedLogs): nothing

Process received logs message (to override in sub classes).

public

receive_metrics(arg_msg: DistributedMetrics): nothing

Process received metrics message (to override in sub classes).

public

receive_msg(arg_msg: DistributedMessage): nothing

Process received message (to override in sub classes).

public

Send a message to an other client.

public

send_logs(arg_target_name: string, arg_timestamp: string, arg_level: string, arg_values: array): boolean

Send a logs message.

public

send_metrics(arg_target_name: string, arg_metric_type: string, arg_metrics: array): boolean

Send a metrics message.

public

send_msg(arg_target_name: string, arg_payload: object, arg_channel: string): boolean

Create and send a message to an other client.

Inherited Summary

From class Loggable
public

Log context.

public

Class type flag.

public

Trace is enabled for this flag.

private

Logger manager instance (default undefined)

public

debug(args: string | array): nothing

Trace DEBUG formatted message.

public

disable_trace(): nothing

Disable traces.

public

enable_trace(): nothing

Enable traces.

public

enter_group(arg_group: string): nothing

Trace INFO message on "enter trace group".

public

error(args: string | array): nothing

Trace ERROR formatted message.

public

Define get class name method for non Instance classes.

public

Get instance context.

public

Get logger manager.

public

Define get instance name method for non Instance classes.

public

Get trace flag.

public

info(args: string | array): nothing

Trace INFO formatted message.

public

leave_group(arg_group: string): nothing

Trace INFO message on "leave trace group".

public

separate_level_1(): nothing

Trace INFO trace level 1 separator.

public

separate_level_2(): nothing

Trace INFO trace level 2 separator.

public

separate_level_3(): nothing

Trace INFO trace level 3 separator.

public

set_trace(arg_value: boolean): nothing

Set trace flag.

public

should_trace(arg_traces_cfg: object): boolean

Calculate should trace flag.

public

should_trace_class(arg_traces_cfg: object): boolean

Calculate should trace flag for classes.

public

should_trace_collection_item(arg_traces_cfg: object, arg_collection_name: string, arg_this_item_accessor: string): boolean

Calculate should trace flag for given collection of names or patterns.

public

should_trace_module(arg_traces_cfg: object): boolean

Calculate should trace flag for modules.

public

should_trace_name(arg_traces_cfg: object): boolean

Calculate should trace flag for instances names.

public

Toggle trace flag.

public

Update trace enabled flag.

public

warn(args: string | array): nothing

Trace WARN formatted message.

From class Errorable
private

Error text (default null).

private

Has error flag (default false).

public

error(arg_msg: string): nothing

Set an error.

public

Default helper for "not implemented" error.

public

Get error message.

public

Test is an error is set.

From class Settingsable
public

$settings: object | Immutable.Map

Instance settings (default undefined).

public

Class type flag.

public

get_setting(arg_name: string | array, arg_default: any): any

Get a value in settings for given key.

public

get_setting_js(arg_name: string | array, arg_default: any): any

Get a value in settings for given key.

public

get_settings(): Immutable.Map

Get instance settings.

public

get_settings_js(): Immutable.Map

Get instance settings.

public

has_setting(arg_name: string): boolean

Test if a key exists in settings.

public

set_setting(arg_name: string, arg_value: any): nothing

Set a value in settings for given key.

public

set_settings(arg_settings: Immutable.Map): nothing

Set instance settings.

From class Stateable
public

Class type flag.

public

state_path: array

State path in runtime state.

private

Initial state.

private

_runtime: Runtime

Runtime isntance.

private

State store.

private

State changes handlers.

public

dispatch_action(arg_action_type: string | object, arg_options: object | undefined): nothing

Dispatch a state action.

public

get_initial_state(): Immutable.Map

Get initial state, an immutable object from a Redux data store.

public

Get name.

public

Get runtime instance.

public

get_state(): Immutable.Map

Get current state, an immutable object from a Redux data store.

public

Get current state, an immutable object from a Redux data store.

public

get_state_path(): array

Get state path into a Redux data store.

public

Get state store.

public

get_state_value(arg_key_or_path: string | array, arg_default_value: any): any

Get a state entry.

public

handle_state_change(arg_previous_state: Immutable.Map, arg_new_state: Immutable.Map): nothing

Handle component state changes.

public

register_state_value_change_handle(arg_path: string | array, arg_listener: string | function): nothing

Register a state value change listener.

From class Instance
public

Instance class name.

public

Instance id.

public

Instance name.

public

Instance collection name.

public

Class type flag.

public

Instance is loaded flag.

public

Get instance class.

public

Get instance description: {$type:..., $class:..., $id:..., $name:...}.

public

Get instance description string: $type:..., $class:..., $id:..., $name:....

public

Get instance unique id.

public

Get instance unique name.

public

Get instance type.

public

Test if this code run inside a browser.

public

Test if this code run on a browser.

public abstract

load(): nothing

Load instance settings.

Public Constructors

public constructor(arg_collection: string, arg_name: string, arg_class: string, arg_settings: object, arg_log_context: string): nothing source

Create a DistributedInstance.

Override:

Instance#constructor

Params:

NameTypeAttributeDescription
arg_collection string

collection name.

arg_name string

server name

arg_class string

server class name

arg_settings object

plugin settings map

arg_log_context string

trace context string (optional, default=context).

Return:

nothing

Public Members

public is_distributed_instance: boolean source

Class type flag.

Private Members

private _bus_unsubscribes: object source

Bus unsubscribes handlers map.

private _logs_bus: MessageBus source

Logs messages bus instance.

private _metrics_bus: MessageBus source

Metrics messages bus instance.

private _msg_bus: MessageBus source

Messages bus instance.

Public Methods

public disable_logs(): nothing source

Disable distributed logs.

Return:

nothing

public disable_metrics(): nothing source

Disable distributed metrics.

Return:

nothing

public disable_msg(): nothing source

Disable distributed messaging.

Return:

nothing

public disable_on_bus(arg_bus: MessageBus, arg_channel: string): nothing source

Disable distributed messaging.

Params:

NameTypeAttributeDescription
arg_bus MessageBus

message bus.

arg_channel string

bus channel string (default='default').

Return:

nothing

public enable_logs(): nothing source

Enable distributed logs.

Return:

nothing

public enable_metrics(): nothing source

Enable distributed metrics.

Return:

nothing

public enable_msg(): nothing source

Enable distributed messaging.

Return:

nothing

public enable_on_bus(arg_bus: MessageBus, arg_channel: string, arg_method: string, arg_alias: string): nothing source

Enable distributed messaging.

Params:

NameTypeAttributeDescription
arg_bus MessageBus

message bus.

arg_channel string

channel name string (default='default').

arg_method string

receiveing method name string (default='receive_msg').

arg_alias string

instance alias name string (optional, default undefined).

Return:

nothing

public load(): nothing source

Load instance settings.

Override:

Instance#load

Return:

nothing

public load_topology_settings(arg_settings: object): nothing source

Load topology settings.

Params:

NameTypeAttributeDescription
arg_settings object

master node settings.

Return:

nothing

public receive_logs(arg_msg: DistributedLogs): nothing source

Process received logs message (to override in sub classes).

Params:

NameTypeAttributeDescription
arg_msg DistributedLogs

logs message instance.

Return:

nothing

public receive_metrics(arg_msg: DistributedMetrics): nothing source

Process received metrics message (to override in sub classes).

Params:

NameTypeAttributeDescription
arg_msg DistributedMetrics

metrics message instance.

Return:

nothing

public receive_msg(arg_msg: DistributedMessage): nothing source

Process received message (to override in sub classes).

Params:

NameTypeAttributeDescription
arg_msg DistributedMessage

message instance.

Return:

nothing

public send(arg_msg: DistributedMessage): boolean source

Send a message to an other client.

Params:

NameTypeAttributeDescription
arg_msg DistributedMessage

message object: a DistributedMessage or DistributedMetrics or DistributedLogs instance.

Return:

boolean

message send or not

public send_logs(arg_target_name: string, arg_timestamp: string, arg_level: string, arg_values: array): boolean source

Send a logs message.

Params:

NameTypeAttributeDescription
arg_target_name string

recipient name.

arg_timestamp string

logs timestamp string.

arg_level string

logs level string.

arg_values array

logs values array.

Return:

boolean

message send or not

public send_metrics(arg_target_name: string, arg_metric_type: string, arg_metrics: array): boolean source

Send a metrics message.

Params:

NameTypeAttributeDescription
arg_target_name string

recipient name.

arg_metric_type string

type of metrics.

arg_metrics array

metrics values array.

Return:

boolean

message send or not

public send_msg(arg_target_name: string, arg_payload: object, arg_channel: string): boolean source

Create and send a message to an other client.

Params:

NameTypeAttributeDescription
arg_target_name string

recipient name.

arg_payload object

message payload plain object.

arg_channel string

channel name string (default='default').

Return:

boolean

message send or not.