AppCallback V1 allows user application to interact with runtime.
User application needs to implement AppCallback service if it needs to
receive message from runtime.
Method Name | Request Type | Response Type | Description |
ListTopicSubscriptions | .google.protobuf.Empty | ListTopicSubscriptionsResponse | Lists all topics subscribed by this app. |
OnTopicEvent | TopicEventRequest | TopicEventResponse | Subscribes events from Pubsub |
ListTopicSubscriptionsResponse is the message including the list of the subscribing topics.
Field | Type | Label | Description |
subscriptions | TopicSubscription | repeated | The list of topics. |
TopicEventRequest message is compatible with CloudEvent spec v1.0
https://github.com/cloudevents/spec/blob/v1.0/spec.md
Field | Type | Label | Description |
id | string | id identifies the event. Producers MUST ensure that source + id is unique for each distinct event. If a duplicate event is re-sent (e.g. due to a network error) it MAY have the same id. |
|
source | string | source identifies the context in which an event happened. Often this will include information such as the type of the event source, the organization publishing the event or the process that produced the event. The exact syntax and semantics behind the data encoded in the URI is defined by the event producer. |
|
type | string | The type of event related to the originating occurrence. |
|
spec_version | string | The version of the CloudEvents specification. |
|
data_content_type | string | The content type of data value. |
|
data | bytes | The content of the event. |
|
topic | string | The pubsub topic which publisher sent to. |
|
pubsub_name | string | The name of the pubsub the publisher sent to. |
|
metadata | TopicEventRequest.MetadataEntry | repeated | add a map to pass some extra properties. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
TopicEventResponse is response from app on published message
Field | Type | Label | Description |
status | TopicEventResponse.TopicEventResponseStatus | The list of output bindings. |
TopicSubscription represents topic and metadata.
Field | Type | Label | Description |
pubsub_name | string | Required. The name of the pubsub containing the topic below to subscribe to. |
|
topic | string | Required. The name of topic which will be subscribed |
|
metadata | TopicSubscription.MetadataEntry | repeated | The optional properties used for this topic's subscription e.g. session id |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
TopicEventResponseStatus allows apps to have finer control over handling of the message.
Name | Number | Description |
SUCCESS | 0 | SUCCESS is the default behavior: message is acknowledged and not retried or logged. |
RETRY | 1 | RETRY status signals runtime to retry the message as part of an expected scenario (no warning is logged). |
DROP | 2 | DROP status signals runtime to drop the message as part of an unexpected scenario (warning is logged). |
Lifecycle API is used to manage the sidecar lifecycle.
For example, by invoking the lifecycle API, you can modify the components' configuration during runtime
Method Name | Request Type | Response Type | Description |
ApplyConfiguration | DynamicConfiguration | ApplyConfigurationResponse | Apply the dynamic configuration. The DynamicConfiguration here should be full configuration, not incremental configuration |
The response of the `ApplyConfiguration` method.
The dynamic configuration of a component
Field | Type | Label | Description |
kind | string | Required. Which kind of API you are using, e.g. `lock`, `state` |
|
name | string | Required. The component name, e.g. `state_demo` |
|
metadata | ComponentConfig.MetadataEntry | repeated | Required. The dynamic configuration of this component |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
The dynamic configuration of the sidecar
Field | Type | Label | Description |
component_config | ComponentConfig | Required. The dynamic configuration of a component |
Runtime encapsulates variours Runtime APIs(such as Configuration API, Pub/Sub API, etc)
Method Name | Request Type | Response Type | Description |
SayHello | SayHelloRequest | SayHelloResponse | SayHello used for test |
InvokeService | InvokeServiceRequest | InvokeResponse | InvokeService do rpc calls |
GetConfiguration | GetConfigurationRequest | GetConfigurationResponse | GetConfiguration gets configuration from configuration store. |
SaveConfiguration | SaveConfigurationRequest | .google.protobuf.Empty | SaveConfiguration saves configuration into configuration store. |
DeleteConfiguration | DeleteConfigurationRequest | .google.protobuf.Empty | DeleteConfiguration deletes configuration from configuration store. |
SubscribeConfiguration | SubscribeConfigurationRequest stream | SubscribeConfigurationResponse stream | SubscribeConfiguration gets configuration from configuration store and subscribe the updates. |
TryLock | TryLockRequest | TryLockResponse | Distributed Lock API A non-blocking method trying to get a lock with ttl. |
Unlock | UnlockRequest | UnlockResponse | A method trying to unlock. |
GetNextId | GetNextIdRequest | GetNextIdResponse | Sequencer API Get next unique id with some auto-increment guarantee |
GetState | GetStateRequest | GetStateResponse | Gets the state for a specific key. |
GetBulkState | GetBulkStateRequest | GetBulkStateResponse | Gets a bulk of state items for a list of keys |
SaveState | SaveStateRequest | .google.protobuf.Empty | Saves an array of state objects |
DeleteState | DeleteStateRequest | .google.protobuf.Empty | Deletes the state for a specific key. |
DeleteBulkState | DeleteBulkStateRequest | .google.protobuf.Empty | Deletes a bulk of state items for a list of keys |
ExecuteStateTransaction | ExecuteStateTransactionRequest | .google.protobuf.Empty | Executes transactions for a specified store |
PublishEvent | PublishEventRequest | .google.protobuf.Empty | Publishes events to the specific topic |
GetFile | GetFileRequest | GetFileResponse stream | Get file with stream |
PutFile | PutFileRequest stream | .google.protobuf.Empty | Put file with stream |
ListFile | ListFileRequest | ListFileResp | List all files |
DelFile | DelFileRequest | .google.protobuf.Empty | Delete specific file |
GetFileMeta | GetFileMetaRequest | GetFileMetaResponse | Get file meta data, if file not exist,return code.NotFound error |
InvokeBinding | InvokeBindingRequest | InvokeBindingResponse | Invokes binding data to specific output bindings |
GetSecret | GetSecretRequest | GetSecretResponse | Gets secrets from secret stores. |
GetBulkSecret | GetBulkSecretRequest | GetBulkSecretResponse | Gets a bulk of secrets |
BulkStateItem is the response item for a bulk get operation.
Return values include the item key, data and etag.
Field | Type | Label | Description |
key | string | state item key |
|
data | bytes | The byte array data |
|
etag | string | The entity tag which represents the specific version of data. ETag format is defined by the corresponding data store. |
|
error | string | The error that was returned from the state store in case of a failed get operation. |
|
metadata | BulkStateItem.MetadataEntry | repeated | The metadata which will be sent to app. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Common invoke request message which includes invoke method and data
Field | Type | Label | Description |
method | string | The method of requset |
|
data | google.protobuf.Any | The request data |
|
content_type | string | The content type of request data |
|
http_extension | HTTPExtension | The extra information of http |
ConfigurationItem represents a configuration item with key, content and other information.
Field | Type | Label | Description |
key | string | Required. The key of configuration item |
|
content | string | The content of configuration item Empty if the configuration is not set, including the case that the configuration is changed from value-set to value-not-set. |
|
group | string | The group of configuration item. |
|
label | string | The label of configuration item. |
|
tags | ConfigurationItem.TagsEntry | repeated | The tag list of configuration item. |
metadata | ConfigurationItem.MetadataEntry | repeated | The metadata which will be passed to configuration store component. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Delete file request message
Field | Type | Label | Description |
request | FileRequest | File request |
DeleteBulkStateRequest is the message to delete a list of key-value states from specific state store.
Field | Type | Label | Description |
store_name | string | Required. The name of state store. |
|
states | StateItem | repeated | Required. The array of the state key values. |
DeleteConfigurationRequest is the message to delete a list of key-value configuration from specified configuration store.
Field | Type | Label | Description |
store_name | string | The name of configuration store. |
|
app_id | string | The application id which Only used for admin, Ignored and reset for normal client |
|
group | string | The group of keys. |
|
label | string | The label for keys. |
|
keys | string | repeated | The keys to get. |
metadata | DeleteConfigurationRequest.MetadataEntry | repeated | The metadata which will be sent to configuration store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
DeleteStateRequest is the message to delete key-value states in the specific state store.
Field | Type | Label | Description |
store_name | string | Required. The name of state store. |
|
key | string | Required. The key of the desired state |
|
etag | Etag | (optional) The entity tag which represents the specific version of data. The exact ETag format is defined by the corresponding data store. |
|
options | StateOptions | (optional) State operation options which includes concurrency/ consistency/retry_policy. |
|
metadata | DeleteStateRequest.MetadataEntry | repeated | (optional) The metadata which will be sent to state store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Etag represents a state item version
Field | Type | Label | Description |
value | string | value sets the etag value |
ExecuteStateTransactionRequest is the message to execute multiple operations on a specified store.
Field | Type | Label | Description |
storeName | string | Required. name of state store. |
|
operations | TransactionalStateOperation | repeated | Required. transactional operation list. |
metadata | ExecuteStateTransactionRequest.MetadataEntry | repeated | (optional) The metadata used for transactional operations. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
File info message
Field | Type | Label | Description |
file_name | string | The name of file |
|
size | int64 | The size of file |
|
last_modified | string | The modified time of file |
|
metadata | FileInfo.MetadataEntry | repeated | The metadata for user extension. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
A map that store FileMetaValue
Field | Type | Label | Description |
metadata | FileMeta.MetadataEntry | repeated | A data structure to store metadata |
Field | Type | Label | Description |
key | string |
|
|
value | FileMetaValue |
|
FileMeta value
Field | Type | Label | Description |
value | string | repeated | File meta value |
File request message
Field | Type | Label | Description |
store_name | string | The name of store |
|
name | string | The name of the directory |
|
metadata | FileRequest.MetadataEntry | repeated | The metadata for user extension. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetBulkSecretRequest is the message to get the secrets from secret store.
Field | Type | Label | Description |
store_name | string | The name of secret store. |
|
metadata | GetBulkSecretRequest.MetadataEntry | repeated | The metadata which will be sent to secret store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetBulkSecretResponse is the response message to convey the requested secrets.
Field | Type | Label | Description |
data | GetBulkSecretResponse.DataEntry | repeated | data hold the secret values. Some secret store, such as kubernetes secret store, can save multiple secrets for single secret key. |
Field | Type | Label | Description |
key | string |
|
|
value | SecretResponse |
|
GetBulkStateRequest is the message to get a list of key-value states from specific state store.
Field | Type | Label | Description |
store_name | string | Required. The name of state store. |
|
keys | string | repeated | Required. The keys to get. |
parallelism | int32 | (optional) The number of parallel operations executed on the state store for a get operation. |
|
metadata | GetBulkStateRequest.MetadataEntry | repeated | (optional) The metadata which will be sent to state store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetBulkStateResponse is the response conveying the list of state values.
Field | Type | Label | Description |
items | BulkStateItem | repeated | The list of items containing the keys to get values for. |
GetConfigurationRequest is the message to get a list of key-value configuration from specified configuration store.
Field | Type | Label | Description |
store_name | string | The name of configuration store. |
|
app_id | string | The application id which Only used for admin, Ignored and reset for normal client |
|
group | string | The group of keys. |
|
label | string | The label for keys. |
|
keys | string | repeated | The keys to get. |
metadata | GetConfigurationRequest.MetadataEntry | repeated | The metadata which will be sent to configuration store components. |
subscribe_update | bool | Subscribes update event for given keys. If true, when any configuration item in this request is updated, app will receive event by OnConfigurationEvent() of app callback |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetConfigurationResponse is the response conveying the list of configuration values.
Field | Type | Label | Description |
items | ConfigurationItem | repeated | The list of items containing configuration values. |
Get fileMeta request message
Field | Type | Label | Description |
request | FileRequest | File meta request |
Get fileMeta response message
Field | Type | Label | Description |
size | int64 | The size of file |
|
last_modified | string | The modified time of file |
|
response | FileMeta | File meta response |
Get file request message
Field | Type | Label | Description |
store_name | string | The name of store |
|
name | string | The name of the file or object want to get. |
|
metadata | GetFileRequest.MetadataEntry | repeated | The metadata for user extension. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Get file response message
Field | Type | Label | Description |
data | bytes | The data of file |
Get next id request message
Field | Type | Label | Description |
store_name | string | Required. Name of sequencer storage |
|
key | string | Required. key is the identifier of a sequencer namespace,e.g. "order_table". |
|
options | SequencerOptions | (optional) SequencerOptions configures requirements for auto-increment guarantee |
|
metadata | GetNextIdRequest.MetadataEntry | repeated | (optional) The metadata which will be sent to the component. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Get next id response message
Field | Type | Label | Description |
next_id | int64 | The next unique id Fixed int64 overflow problems on JavaScript https://github.com/improbable-eng/ts-protoc-gen#gotchas |
GetSecretRequest is the message to get secret from secret store.
Field | Type | Label | Description |
store_name | string | The name of secret store. |
|
key | string | The name of secret key. |
|
metadata | GetSecretRequest.MetadataEntry | repeated | The metadata which will be sent to secret store components. Contains version, status, and so on... |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetSecretResponse is the response message to convey the requested secret.
Field | Type | Label | Description |
data | GetSecretResponse.DataEntry | repeated | data is the secret value. Some secret store, such as kubernetes secret store, can save multiple secrets for single secret key. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetStateRequest is the message to get key-value states from specific state store.
Field | Type | Label | Description |
store_name | string | Required. The name of state store. |
|
key | string | Required. The key of the desired state |
|
consistency | StateOptions.StateConsistency | (optional) read consistency mode |
|
metadata | GetStateRequest.MetadataEntry | repeated | (optional) The metadata which will be sent to state store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
GetStateResponse is the response conveying the state value and etag.
Field | Type | Label | Description |
data | bytes | The byte array data |
|
etag | string | The entity tag which represents the specific version of data. ETag format is defined by the corresponding data store. |
|
metadata | GetStateResponse.MetadataEntry | repeated | The metadata which will be sent to app. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Http extension message is about invoke http information
Field | Type | Label | Description |
verb | HTTPExtension.Verb | The method of http reuest |
|
querystring | string | The query information of http |
InvokeBindingRequest is the message to send data to output bindings
Field | Type | Label | Description |
name | string | The name of the output binding to invoke. |
|
data | bytes | The data which will be sent to output binding. |
|
metadata | InvokeBindingRequest.MetadataEntry | repeated | The metadata passing to output binding components Common metadata property: - ttlInSeconds : the time to live in seconds for the message. If set in the binding definition will cause all messages to have a default time to live. The message ttl overrides any value in the binding definition. |
operation | string | The name of the operation type for the binding to invoke |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
InvokeBindingResponse is the message returned from an output binding invocation
Field | Type | Label | Description |
data | bytes | The data which will be sent to output binding. |
|
metadata | InvokeBindingResponse.MetadataEntry | repeated | The metadata returned from an external system |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Invoke service response message is result of invoke service queset
Field | Type | Label | Description |
data | google.protobuf.Any | The response data |
|
content_type | string | The content type of response data |
Invoke service request message
Field | Type | Label | Description |
id | string | The identify of InvokeServiceRequest |
|
message | CommonInvokeRequest | InvokeServiceRequest message |
List file request message
Field | Type | Label | Description |
request | FileRequest | File request |
|
page_size | int32 | Page size |
|
marker | string | Marker |
List file response message
Field | Type | Label | Description |
files | FileInfo | repeated | File info |
marker | string | Marker |
|
is_truncated | bool | Is truncated |
PublishEventRequest is the message to publish event data to pubsub topic
Field | Type | Label | Description |
pubsub_name | string | The name of the pubsub component |
|
topic | string | The pubsub topic |
|
data | bytes | The data which will be published to topic. |
|
data_content_type | string | The content type for the data (optional). |
|
metadata | PublishEventRequest.MetadataEntry | repeated | The metadata passing to pub components metadata property: - key : the key of the message. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
Put file request message
Field | Type | Label | Description |
store_name | string | The name of store |
|
name | string | The name of the file or object want to put. |
|
data | bytes | The data will be store. |
|
metadata | PutFileRequest.MetadataEntry | repeated | The metadata for user extension. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
SaveConfigurationRequest is the message to save a list of key-value configuration into specified configuration store.
Field | Type | Label | Description |
store_name | string | The name of configuration store. |
|
app_id | string | The application id which Only used for admin, ignored and reset for normal client |
|
items | ConfigurationItem | repeated | The list of configuration items to save. To delete a exist item, set the key (also label) and let content to be empty |
metadata | SaveConfigurationRequest.MetadataEntry | repeated | The metadata which will be sent to configuration store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
SaveStateRequest is the message to save multiple states into state store.
Field | Type | Label | Description |
store_name | string | Required. The name of state store. |
|
states | StateItem | repeated | Required. The array of the state key values. |
Hello request message
Field | Type | Label | Description |
service_name | string | The name of service |
|
name | string | Reuqest name |
|
data | google.protobuf.Any | Optional. This field is used to control the packet size during load tests. |
Hello response message
Field | Type | Label | Description |
hello | string | Hello |
|
data | google.protobuf.Any | Hello message of data |
SecretResponse is a map of decrypted string/string values
Field | Type | Label | Description |
secrets | SecretResponse.SecretsEntry | repeated | The data struct of secrets |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
SequencerOptions configures requirements for auto-increment guarantee
Field | Type | Label | Description |
increment | SequencerOptions.AutoIncrement | Default STRONG auto-increment |
StateItem represents state key, value, and additional options to save state.
Field | Type | Label | Description |
key | string | Required. The state key |
|
value | bytes | Required. The state data for key |
|
etag | Etag | (optional) The entity tag which represents the specific version of data. The exact ETag format is defined by the corresponding data store. Layotto runtime only treats ETags as opaque strings. |
|
metadata | StateItem.MetadataEntry | repeated | (optional) additional key-value pairs to be passed to the state store. |
options | StateOptions | (optional) Options for concurrency and consistency to save the state. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
StateOptions configures concurrency and consistency for state operations
Field | Type | Label | Description |
concurrency | StateOptions.StateConcurrency | The state operation of concurrency |
|
consistency | StateOptions.StateConsistency | The state operation of consistency |
SubscribeConfigurationRequest is the message to get a list of key-value configuration from specified configuration store.
Field | Type | Label | Description |
store_name | string | The name of configuration store. |
|
app_id | string | The application id which Only used for admin, ignored and reset for normal client |
|
group | string | The group of keys. |
|
label | string | The label for keys. |
|
keys | string | repeated | The keys to get. |
metadata | SubscribeConfigurationRequest.MetadataEntry | repeated | The metadata which will be sent to configuration store components. |
Field | Type | Label | Description |
key | string |
|
|
value | string |
|
SubscribeConfigurationResponse is the response conveying the list of configuration values.
Field | Type | Label | Description |
store_name | string | The name of configuration store. |
|
app_id | string | The application id. Only used for admin client. |
|
items | ConfigurationItem | repeated | The list of items containing configuration values. |
TransactionalStateOperation is the message to execute a specified operation with a key-value pair.
Field | Type | Label | Description |
operationType | string | Required. The type of operation to be executed. Legal values include: "upsert" represents an update or create operation "delete" represents a delete operation |
|
request | StateItem | Required. State values to be operated on |
Lock request message is distributed lock API which is not blocking method tring to get a lock with ttl
Field | Type | Label | Description |
store_name | string | Required. The lock store name,e.g. `redis`. |
|
resource_id | string | Required. resource_id is the lock key. e.g. `order_id_111` It stands for "which resource I want to protect" |
|
lock_owner | string | Required. lock_owner indicate the identifier of lock owner. You can generate a uuid as lock_owner.For example,in golang: req.LockOwner = uuid.New().String() This field is per request,not per process,so it is different for each request, which aims to prevent multi-thread in the same process trying the same lock concurrently. The reason why we don't make it automatically generated is: 1. If it is automatically generated,there must be a 'my_lock_owner_id' field in the response. This name is so weird that we think it is inappropriate to put it into the api spec 2. If we change the field 'my_lock_owner_id' in the response to 'lock_owner',which means the current lock owner of this lock, we find that in some lock services users can't get the current lock owner.Actually users don't need it at all. 3. When reentrant lock is needed,the existing lock_owner is required to identify client and check "whether this client can reenter this lock". So this field in the request shouldn't be removed. |
|
expire | int32 | Required. expire is the time before expire.The time unit is second. |
Lock response message returns is the lock obtained.
Field | Type | Label | Description |
success | bool | Is lock success |
UnLock request message
Field | Type | Label | Description |
store_name | string | The name of store |
|
resource_id | string | resource_id is the lock key. |
|
lock_owner | string | The owner of the lock |
UnLock response message
Field | Type | Label | Description |
status | UnlockResponse.Status | The status of unlock |
The enum of http reuest method
Name | Number | Description |
NONE | 0 | NONE |
GET | 1 | GET method |
HEAD | 2 | HEAD method |
POST | 3 | POST method |
PUT | 4 | PUT method |
DELETE | 5 | DELETE method |
CONNECT | 6 | CONNECT method |
OPTIONS | 7 | CONNECT method |
TRACE | 8 | CONNECT method |
PATCH | 9 | PATCH method |
requirements for auto-increment guarantee
Name | Number | Description |
WEAK | 0 | (default) WEAK means a "best effort" incrementing service.But there is no strict guarantee of global monotonically increasing. The next id is "probably" greater than current id. |
STRONG | 1 | STRONG means a strict guarantee of global monotonically increasing. The next id "must" be greater than current id. |
Enum describing the supported concurrency for state.
The API server uses Optimized Concurrency Control (OCC) with ETags.
When an ETag is associated with an save or delete request, the store shall allow the update only if the attached ETag matches with the latest ETag in the database.
But when ETag is missing in the write requests, the state store shall handle the requests in the specified strategy(e.g. a last-write-wins fashion).
Name | Number | Description |
CONCURRENCY_UNSPECIFIED | 0 | Concurrency state is unspecified |
CONCURRENCY_FIRST_WRITE | 1 | First write wins |
CONCURRENCY_LAST_WRITE | 2 | Last write wins |
Enum describing the supported consistency for state.
Name | Number | Description |
CONSISTENCY_UNSPECIFIED | 0 | Consistency state is unspecified |
CONSISTENCY_EVENTUAL | 1 | The API server assumes data stores are eventually consistent by default.A state store should: - For read requests, the state store can return data from any of the replicas - For write request, the state store should asynchronously replicate updates to configured quorum after acknowledging the update request. |
CONSISTENCY_STRONG | 2 | When a strong consistency hint is attached, a state store should: - For read requests, the state store should return the most up-to-date data consistently across replicas. - For write/delete requests, the state store should synchronisely replicate updated data to configured quorum before completing the write request. |
The enum of unlock status
Name | Number | Description |
SUCCESS | 0 | Unlock is success |
LOCK_UNEXIST | 1 | The lock is not exist |
LOCK_BELONG_TO_OTHERS | 2 | The lock is belong to others |
INTERNAL_ERROR | 3 | Internal error |
.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) |