Class: ReplicatedEntity

akkaserverless.replicatedentity. ReplicatedEntity

A Replicated Entity.


new ReplicatedEntity(desc, serviceName, entityType [, options])

Create a Replicated Entity.

Parameters:
Name Type Argument Description
desc string | Array.<string>

The file name of a protobuf descriptor or set of descriptors containing the Replicated Entity service.

serviceName string

The fully qualified name of the gRPC service that this Replicated Entity implements.

entityType string

The entity type name, used to namespace entities of different Replicated Data types in the same service.

options module:akkaserverless.replicatedentity.ReplicatedEntity~options <optional>

The options for this entity.

Implements:

Members


commandHandlers :Object.<string, module:akkaserverless.replicatedentity.ReplicatedEntity~commandHandler>

The command handlers.

The names of the properties must match the names of the service calls specified in the gRPC descriptor for this Replicated Entity service.

Type:

defaultValue :module:akkaserverless.replicatedentity.ReplicatedEntity~defaultValueCallback

A callback that is invoked to create a default value if the Akka Serverless proxy doesn't send an existing one.

Type:

onStateSet :module:akkaserverless.replicatedentity.ReplicatedEntity~onStateSetCallback

A callback that is invoked whenever the Replicated Data state is set for this Replicated Entity.

This is invoked whenever a new Replicated Data state is set on the Replicated Entity, to allow the state to be enriched with domain specific properties and methods. This may be due to the state being set explicitly from a command handler on the command context, or implicitly as the default value, or implicitly when a new state is received from the proxy.

Type:

options :module:akkaserverless.replicatedentity.ReplicatedEntity~options

Type:

service :protobuf.Service

Type:
  • protobuf.Service

serviceName :string

Type:
  • string

Methods


componentType()

Returns:

replicated entity component type.

Type
string

lookupType(messageType)

Lookup a Protobuf message type.

This is provided as a convenience to lookup protobuf message types for use, for example, as values in sets and maps.

Parameters:
Name Type Description
messageType string

The fully qualified name of the type to lookup.

Returns:

The protobuf message type.

Type
protobuf.Type

Type Definitions


commandHandler(command, context)

A command handler callback.

Parameters:
Name Type Description
command Object

The command message, this will be of the type of the gRPC service call input type.

context module:akkaserverless.replicatedentity.ReplicatedEntityCommandContext

The command context.

Returns:

The message to reply with, it must match the gRPC service call output type for this command.

Type
undefined | Object

defaultValueCallback(entityId)

A callback that is invoked to create a default value if the Akka Serverless proxy doesn't send an existing one.

Parameters:
Name Type Description
entityId string

The id of the entity.

Returns:

The default value to use for this entity.

Type
Object

entityPassivationStrategy

Entity passivation strategy for a replicated entity.

Properties:
Name Type Argument Description
timeout number <optional>

Passivation timeout (in milliseconds).


onStateSetCallback(state, entityId)

A state set handler callback.

This is invoked whenever a new state is set on the Replicated Entity, to allow the state to be enriched with domain specific properties and methods. This may be due to the state being set explicitly from a command handler on the command context, or implicitly as the default value, or implicitly when a new state is received from the proxy.

Parameters:
Name Type Description
state module:akkaserverless.replicatedentity.ReplicatedData

The Replicated Data state that was set.

entityId string

The id of the entity.


options

Options for creating a Replicated Entity.

Properties:
Name Type Argument Default Description
includeDirs array.<string> <optional>
["."]

The directories to include when looking up imported protobuf files.

entityPassivationStrategy module:akkaserverless.replicatedentity.ReplicatedEntity~entityPassivationStrategy <optional>

Entity passivation strategy to use.

replicatedWriteConsistency module:akkaserverless.ReplicatedWriteConsistency <optional>

Write consistency to use for this replicated entity.