Class: ValueEntity

akkaserverless. ValueEntity

A value entity.


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

Create a new value entity.

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

A descriptor or list of descriptors to parse, containing the service to serve.

serviceName string

The fully qualified name of the service that provides this entities interface.

entityType string

The entity type name for all value entities of this type. Never change it after deploying a service that stored data of this type

options module:akkaserverless.ValueEntity~options <optional>

The options for this entity

Implements:

Members


commandHandlers :module:akkaserverless.ValueEntity~commandHandlers

The command handlers.

Type:

initial :module:akkaserverless.ValueEntity~initialCallback

The initial state callback.

Type:

options :module:akkaserverless.ValueEntity~options

Type:

service :protobuf.Service

Type:
  • protobuf.Service

serviceName :string

Type:
  • string

Methods


componentType()

Returns:

value 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 with state.

Parameters:
Name Type Description
messageType string

The fully qualified name of the type to lookup.

Returns:

The protobuf message type.

Type
protobuf.Type

setCommandHandlers(handlers)

Set the command handlers of the entity.

Parameters:
Name Type Description
handlers module:akkaserverless.ValueEntity~commandHandlers

The command handler callbacks.

Returns:

This entity.

Type
module:akkaserverless.ValueEntity

setInitial(callback)

Set the initial state callback.

Parameters:
Name Type Description
callback module:akkaserverless.ValueEntity~initialCallback

The initial state callback.

Returns:

This entity.

Type
module:akkaserverless.ValueEntity

Type Definitions


commandHandler(command, state, context)

A command handler for one service call to the value entity

Parameters:
Name Type Description
command Object

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

state module:akkaserverless.Serializable

The entity state.

context module:akkaserverless.ValueEntity.ValueEntityCommandContext

The command context.

Returns:

The message to reply with, it must match the gRPC service call output type for this command, or if a Reply is returned, contain an object that matches the output type.

Type
undefined | Object | module:akkaserverless.replies.Reply

commandHandlers

Value entity command handlers The names of the properties must match the names of the service calls specified in the gRPC descriptor for this value entities service.

Type:

entityPassivationStrategy

Entity passivation strategy for a value entity.

Properties:
Name Type Argument Description
timeout number <optional>

Passivation timeout (in milliseconds).


initialCallback(entityId)

Initial state callback.

This is invoked if the entity is started with no snapshot.

Parameters:
Name Type Description
entityId string

The entity id.

Returns:

The entity state.

Type
module:akkaserverless.Serializable

options

Options for a value entity.

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

The directories to include when looking up imported protobuf files.

serializeAllowPrimitives boolean <optional>
false

Whether serialization of primitives should be supported when serializing the state.

serializeFallbackToJson boolean <optional>
false

Whether serialization should fallback to using JSON if the state can't be serialized as a protobuf.

forwardHeaders array.<string> <optional>
[]

request headers to be forwarded as metadata to the value entity

entityPassivationStrategy module:akkaserverless.ValueEntity~entityPassivationStrategy <optional>

Entity passivation strategy to use.