Cache is a persisted value that will expire after a period of time. It is held in memory for maximum performance.
Field | Type | Label | Description |
domain | string | the cached value's business domain(ex: accounting) |
|
key | string | the cached value's key (unique within domain) |
|
value | google.protobuf.Value | the cached value's value to store |
|
exp | google.protobuf.Timestamp | exp is the time at which the cached value will expire if exp is 0, the value will never expire |
Field | Validations |
domain |
|
key |
|
value |
|
CacheRef is a reference to a cached value
Field | Type | Label | Description |
domain | string | the cached value's business domain(ex: accounting) must not be empty or contain spaces |
|
key | string | cached value's key (unique within domain) must not be empty or contain spaces |
Field | Validations |
domain |
|
key |
|
Entities is an array of Entity
Field | Type | Label | Description |
entities | Entity | repeated |
|
Entity represents a single record(k/v pairs) with a unique key with a given [type](https://en.wikipedia.org/wiki/Type_system), belonging to a particular [domain](https://en.wikipedia.org/wiki/Domain-driven_design)
EventService clients should use the EntityService to persist & interact with the current state of an entity.
Field | Type | Label | Description |
domain | string | the entity's business domain(ex: accounting) must not be empty or contain spaces |
|
type | string | the entity's type (ex: user) must not be empty or contain spaces |
|
key | string | the entity's key (unique within type). must not be empty or contain spaces |
|
values | google.protobuf.Struct | the entity's values (k/v pairs) |
Field | Validations |
domain |
|
type |
|
key |
|
values |
|
EntityRef is a reference to an existing entity
Field | Type | Label | Description |
domain | string | the entity's business domain(ex: accounting) must not be empty or contain spaces |
|
type | string | entity type (ex: user) must not be empty or contain spaces |
|
key | string | entity key (unique within type) must not be empty or contain spaces |
Field | Validations |
domain |
|
type |
|
key |
|
Event is primitive that represents a single state change to an entity
Events are persisted to history & broadcasted to interested consumers(Stream) any time an entity is created/modified/deleted
Events are immutable after creation and may be searched.
EventService client's may search events to query previous state of an entity(s)
Field | Type | Label | Description |
id | string | identifies the event(uuid v4). |
|
entity | Entity | state of an Entity after it has been mutated |
|
method | string | the invoked method that triggered the event |
|
claims | google.protobuf.Struct | the authentication claims of the event producer. |
|
time | int64 | timestamp(ns) of when the event was received. |
Field | Validations |
id |
|
entity |
|
method |
|
claims |
|
time |
|
EventRef holds options for reverting an entity to a previous version of itself
Field | Type | Label | Description |
domain | string | the event's entity's business domain(ex: accounting) must not be empty or contain spaces |
|
type | string | event entity type (ex: user) must not be empty or contain spaces |
|
key | string | event's entity's key (unique within type) must not be empty or contain spaces |
|
id | string | id is the event id. |
Field | Validations |
domain |
|
type |
|
key |
|
id |
|
Events is an array of events
Field | Type | Label | Description |
events | Event | repeated |
|
Message is an arbitrary message to be delivered to a Peer
Messages are NOT persisted and should only be used to communicate with other Peers
Field | Type | Label | Description |
domain | string | the message's business domain(ex: accounting) must not be empty or contain spaces |
|
channel | string | the message's channel(ex: general) must not be empty or contain spaces |
|
type | string | message's type (ex: comment) must not be empty or contain spaces |
|
body | google.protobuf.Struct | the body of the message(k/v values). |
Field | Validations |
domain |
|
channel |
|
type |
|
body |
|
Mutex is a distributed mutex for preventing data-races amongst peer services
Field | Type | Label | Description |
domain | string | the mutex's business domain(ex: accounting) |
|
key | string | mutex key (unique within domain) |
|
exp | google.protobuf.Timestamp | exp is the time at which the mutex value will expire if exp is 0, the mutex will never expire |
Field | Validations |
domain |
|
key |
|
MutexRef is a reference to a distributed mutex
Field | Type | Label | Description |
domain | string | the mutex's business domain(ex: accounting) |
|
key | string | mutex key (unique within domain) |
Field | Validations |
domain |
|
key |
|
PeerMessage is a message produced by a client to the PeerService
PeerMessages are NOT persisted and should only be used to communicate with other Peers
Field | Type | Label | Description |
id | string | the unique id of the message |
|
domain | string | the message's business domain(ex: accounting) must not be empty or contain spaces |
|
channel | string | the message's channel(ex: general) must not be empty or contain spaces |
|
type | string | message's type (ex: comment) must not be empty or contain spaces |
|
body | google.protobuf.Struct | the body of the message(k/v values). |
|
claims | google.protobuf.Struct | the authentication claims of the message producer. |
|
time | int64 | timestamp(ns) of when the message was broadcasted. |
Field | Validations |
id |
|
domain |
|
channel |
|
type |
|
body |
|
claims |
|
time |
|
SearchEntityOpts are options when querying the current values of entities.
If historical values are needed, SearchEvents should be used
Field | Type | Label | Description |
domain | string | the entity's business domain(ex: accounting) must not be empty or contain spaces |
|
type | string | State type (ex: user) must not be empty or contain spaces |
|
query_string | string | json string to filter records that have values match k/v pairs ex: { "message": "hello world" } please note that dot notation may be used to access nested fields |
|
limit | int32 | limit number of returned values |
|
offset | int32 | offset returned events(pagination) |
|
sort | Sort | sort sorts the returned entities by a specified field |
Field | Validations |
domain |
|
type |
|
limit |
|
SearchEventOpts are options when querying historical events emitted from mutations made from State mutations
Field | Type | Label | Description |
domain | string | the entity's business domain(ex: accounting) must not be empty or contain spaces |
|
type | string | entity's type (ex: user) must not be empty or contain spaces |
|
query_string | string | json string to filter events based with values that match k/v pairs ex: { "entity.values.message": "hello world" }. please note that dot notation may be used to access nested fields |
|
min | int64 | only return events that occurred after specified min timestamp |
|
max | int64 | only return events that occurred before specified max timestamp |
|
limit | int32 | limit number of returned values |
|
offset | int32 | offset returned events(pagination) |
|
sort | Sort | sort sorts the returned entities by a specified field |
Field | Validations |
domain |
|
type |
|
limit |
|
Sort is a primitive used to sort an array
Field | Type | Label | Description |
field | string | field is a field to sort the array by please note that dot notation may be used to access nested fields |
|
reverse | bool | reverse reverses the direction of the sort |
StreamEventOpts are options for consumers looking to stream events.
Events are automatically emitted from mutations made from State mutations within the EntityService
Field | Type | Label | Description |
domain | string | the domain of the entity (ex: acme) that triggered the event * indicates any domain must not be empty or contain spaces |
|
type | string | the type of the entity (ex: user) that triggered the event * indicates any type must not be empty or contain spaces |
|
consumer_group | string | consumer_group |
Field | Validations |
domain |
|
type |
|
StreamMessageOpts holds options for streaming messages produced by Peers
Field | Type | Label | Description |
domain | string | the message's business domain(ex: accounting) to subscribe to must not be empty or contain spaces * indicates any domain |
|
channel | string | the message's channel(ex: general) to subscribe to must not be empty or contain spaces * indicates any channel |
|
type | string | message's type (ex: comment) to subscribe to must not be empty or contain spaces * indicates any type |
|
consumer_group | string | consumer_group |
Field | Validations |
domain |
|
channel |
|
type |
|
CacheService is for persisting short lived values in memory for performance-critical operations
Method Name | Request Type | Response Type | Description |
Set | Cache | .google.protobuf.Empty | Set sets a value in the cache |
Get | CacheRef | Cache | Get gets a value from the cache |
Del | CacheRef | .google.protobuf.Empty | Del deletes a value from the cache |
Method Name | Method | Pattern | Body |
Set | PUT | /api/cache/ref/{domain}/{key} | |
Get | GET | /api/cache/ref/{domain}/{key} | |
Del | DELETE | /api/cache/ref/{domain}/{key} |
EntityService serves API methods to clients that modify/query the current state of an entity
An Entity is a single object with a type, domain, key, and k/v values
Method Name | Request Type | Response Type | Description |
Set | Entity | .google.protobuf.Empty | Set sets the current state value of an entity, adds it to the event log, then broadcast the event to all interested consumers(EventService.Stream) |
Edit | Entity | Entity | Edit overwrites the k/v pairs present in the entity request without replacing the entire entity. It then adds the state change to the event log, then broadcast the event to all interested consumers(EventService.Stream) Edit returns the current state of the Entity after the mutation. |
Revert | EventRef | Entity | Revert reverts an Entity to a previous version of itself by querying the event store. Reverting an entity dispatches another event since it is a state change |
Get | EntityRef | Entity | Get gets an entity's current state |
Del | EntityRef | .google.protobuf.Empty | Del hard deletes an entity from current state store, adds it's state prior to deletion to the event log, then broadcast the event to all interested consumers(EventService.Stream) an Entity may be recovered via querying the Event store for historical records of the deleted Entity. |
Search | SearchEntityOpts | Entities | Search queries the current state of entities |
Method Name | Method | Pattern | Body |
Set | PUT | /api/entity/ref/{domain}/{type}/{key} | |
Edit | PATCH | /api/entity/ref/{domain}/{type}/{key} | |
Revert | PUT | /api/entity/ref/{domain}/{type}/{key}/revert | |
Get | GET | /api/entity/ref/{domain}/{type}/{key} | |
Del | DELETE | /api/entity/ref/{domain}/{type}/{key} | |
Search | GET | /api/entity/search |
EventService serves API methods related to stategate Event Consumers
Events are automatically emitted from mutations made from State mutations within the EntityService
Method Name | Request Type | Response Type | Description |
Stream | StreamEventOpts | Event stream | Stream creates an event stream/subscription to state changes to entities in real time. Glob matching is supported. |
Search | SearchEventOpts | Events | Search queries historical events - every historical state change to an entity may be queried. |
Get | EventRef | Event | Get gets a single event |
Method Name | Method | Pattern | Body |
Stream | GET | /api/event/stream | |
Search | GET | /api/event/search | |
Get | GET | /api/event/ref/{domain}/{type}/{key}/{id} |
MutexService offers distributed locking capabilities for client's that need to coordinate with peer services.
Method Name | Request Type | Response Type | Description |
Lock | Mutex | .google.protobuf.Empty | Lock locks a value for a period of time if it is not locked already. If it is already locked, an error will be returned It is best practice for client's to call Unlock when the distributed lock operation is completed instead of relying on the TTL |
Unlock | MutexRef | .google.protobuf.Empty | Unlock unlocks the key(if it's currently locked) so that it may be locked again. It is best practice for client's to call Unlock when the distributed lock operation is completed instead of relying on the TTL |
Method Name | Method | Pattern | Body |
Lock | PUT | /api/mutex/ref/{domain}/{key} | |
Unlock | PUT | /api/mutex/ref/{domain}/{key} |
PeerService provides a means for clients to communicate directly with one another WITHOUT making any state changes.
Please note that all messages transported via the PeerService are not persisted in any way.
Method Name | Request Type | Response Type | Description |
Broadcast | Message | .google.protobuf.Empty | Broadcast broadcasts a message to N subscribers(clients calling Stream) |
Stream | StreamMessageOpts | PeerMessage stream | Stream consumes/streams messages from message producers(clients calling broadcast) |
Method Name | Method | Pattern | Body |
Broadcast | POST | /api/peer/broadcast | * |
Stream | GET | /api/peer/stream |
.proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
double | double | double | float | float64 | double | float | Float | |
float | float | float | float | float32 | float | float | Float | |
int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum |
uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) |
uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) |
sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum |
fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) |
fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum |
sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum |
bool | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | |
string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |