Protobuf
You can use protocol buffers (aka protobuf) to define your API for either TypeScript or Python backends.
To declare a data type called Hello
, put the following in a .proto
file:
message Hello {
option (rbt.v1alpha1.state) = {
};
repeated string messages = 1;
}
Reboot uses standard Protobuf definitions, but take note of the rbt
options (aka, annotations), which requires you adding import "rbt/v1alpha1/options.proto";
.
In the above example, rbt.v1alpha1.state
declares that message Hello
is a Reboot data type.
In addition to defining the data type, you'll also need to define operations for that type, for example:
service HelloMethods {
// Returns the current list of recorded messages.
rpc Messages(MessagesRequest) returns (MessagesResponse) {
option (rbt.v1alpha1.method).reader = {
};
}
// Adds a new message to the list of recorded messages.
rpc Send(SendRequest) returns (SendResponse) {
option (rbt.v1alpha1.method).writer = {
};
}
}
The current convention is that a state's interface has the same name
as the state with the suffix Methods
.
For each of the rpc
methods that you declare, you use the
rbt.v1alpha1.method
annotation to specify the method
kind.
Depending on its kind, a method
might be able to only read (e.g., reader
) or both read and write
(e.g., writer
) the state.
In the example above, Hello
has just one reader
and one writer
method, but it can have any number of reader
, writer
,
transaction
, and workflow
methods.
To learn more about how you implement each data type's methods see Implementing your API.