Documentation ¶
Index ¶
- Constants
- func CoroutineState(state Any) interface{ ... }
- func CorrelationID(correlationID uint64) interface{ ... }
- func DispatchID(id ID) interface{ ... }
- func Input(input Any) interface{ ... }
- func Output(output Any) interface{ ... }
- type Any
- type Call
- func (c Call) Clone() Call
- func (c Call) CorrelationID() uint64
- func (c Call) Endpoint() string
- func (c Call) Equal(other Call) bool
- func (c Call) Expiration() time.Duration
- func (c Call) Function() string
- func (c Call) Input() Any
- func (c Call) Request() Request
- func (c Call) String() string
- func (c Call) Version() string
- func (c Call) With(opts ...CallOption) Call
- type CallOption
- type CallResult
- func (r CallResult) Clone() CallResult
- func (r CallResult) CorrelationID() uint64
- func (r CallResult) DispatchID() ID
- func (r CallResult) Equal(other CallResult) bool
- func (r CallResult) Error() (Error, bool)
- func (r CallResult) Output() (Any, bool)
- func (r CallResult) String() string
- func (r CallResult) With(opts ...CallResultOption) CallResult
- type CallResultOption
- type Error
- type ErrorOption
- type Exit
- type ExitOption
- type Function
- type FunctionMap
- type ID
- type Poll
- type PollOption
- type PollResult
- func (r PollResult) Clone() PollResult
- func (r PollResult) CoroutineState() Any
- func (r PollResult) Equal(other PollResult) bool
- func (r PollResult) Error() (Error, bool)
- func (r PollResult) Results() []CallResult
- func (r PollResult) String() string
- func (r PollResult) With(opts ...PollResultOption) PollResult
- type PollResultOption
- type Request
- func (r Request) Clone() Request
- func (r Request) CreationTime() (time.Time, bool)
- func (r Request) DispatchID() ID
- func (r Request) Equal(other Request) bool
- func (r Request) ExpirationTime() (time.Time, bool)
- func (r Request) Function() string
- func (r Request) Input() (Any, bool)
- func (r Request) ParentID() ID
- func (r Request) PollResult() (PollResult, bool)
- func (r Request) RootID() ID
- func (r Request) String() string
- func (r Request) With(opts ...RequestOption) Request
- type RequestOption
- type Response
- func (r Response) Clone() Response
- func (r Response) Equal(other Response) bool
- func (r Response) Error() (Error, bool)
- func (r Response) Exit() (Exit, bool)
- func (r Response) Marshal() ([]byte, error)
- func (r Response) OK() bool
- func (r Response) Output() (Any, bool)
- func (r Response) Poll() (Poll, bool)
- func (r Response) Result() (CallResult, bool)
- func (r Response) Status() Status
- func (r Response) String() string
- func (r Response) With(opts ...ResponseOption) Response
- type ResponseOption
- type Status
- type StatusError
Constants ¶
const ( UnspecifiedStatus = Status(sdkv1.Status_STATUS_UNSPECIFIED) OKStatus = Status(sdkv1.Status_STATUS_OK) TimeoutStatus = Status(sdkv1.Status_STATUS_TIMEOUT) ThrottledStatus = Status(sdkv1.Status_STATUS_THROTTLED) InvalidArgumentStatus = Status(sdkv1.Status_STATUS_INVALID_ARGUMENT) InvalidResponseStatus = Status(sdkv1.Status_STATUS_INVALID_RESPONSE) TemporaryErrorStatus = Status(sdkv1.Status_STATUS_TEMPORARY_ERROR) PermanentErrorStatus = Status(sdkv1.Status_STATUS_PERMANENT_ERROR) IncompatibleStateStatus = Status(sdkv1.Status_STATUS_INCOMPATIBLE_STATE) DNSErrorStatus = Status(sdkv1.Status_STATUS_DNS_ERROR) TCPErrorStatus = Status(sdkv1.Status_STATUS_TCP_ERROR) TLSErrorStatus = Status(sdkv1.Status_STATUS_TLS_ERROR) HTTPErrorStatus = Status(sdkv1.Status_STATUS_HTTP_ERROR) UnauthenticatedStatus = Status(sdkv1.Status_STATUS_UNAUTHENTICATED) PermissionDeniedStatus = Status(sdkv1.Status_STATUS_PERMISSION_DENIED) NotFoundStatus = Status(sdkv1.Status_STATUS_NOT_FOUND) )
Variables ¶
This section is empty.
Functions ¶
func CoroutineState ¶
func CoroutineState(state Any) interface { PollOption PollResultOption ResponseOption }
CoroutineState sets the coroutine state.
func CorrelationID ¶
func CorrelationID(correlationID uint64) interface { CallOption CallResultOption }
CorrelationID sets the correlation ID on a function call or result.
func DispatchID ¶
func DispatchID(id ID) interface { CallResultOption RequestOption }
DispatchID sets the opaque identifier for the function call.
func Input ¶
func Input(input Any) interface { CallOption RequestOption }
Input sets the output from a function call or Response.
func Output ¶
func Output(output Any) interface { CallResultOption ExitOption ResponseOption }
Output sets the output from a function call or Response.
Types ¶
type Any ¶
type Any struct {
// contains filtered or unexported fields
}
Any represents any value.
func Marshal ¶
Marshal packages a Go value into an Any, for use as input to or output from a Dispatch function.
Primitive values (booleans, integers, floats, strings, bytes, timestamps, durations) are supported, along with values that implement either proto.Message, json.Marshaler, encoding.TextMarshaler or encoding.BinaryMarshaler. Slices and maps are also supported, as long as they are JSON-like in shape.
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call is a function call.
func NewCall ¶
func NewCall(endpoint, function string, opts ...CallOption) Call
NewCall creates a Call.
func (Call) CorrelationID ¶
CorrelationID is an opaque value that gets repeated in CallResult to correlate asynchronous calls with their results.
func (Call) Expiration ¶
Expiration is the maximum time the function is allowed to run.
func (Call) Version ¶
Version of the application to select during execution. The version is an optional field and not supported by all platforms.
func (Call) With ¶
func (c Call) With(opts ...CallOption) Call
With creates a copy of the Call with additional options applied.
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption configures a Call.
func Expiration ¶
func Expiration(expiration time.Duration) CallOption
Expiration sets a function call expiration.
type CallResult ¶
type CallResult struct {
// contains filtered or unexported fields
}
CallResult is a function call result.
func NewCallResult ¶
func NewCallResult(opts ...CallResultOption) CallResult
NewCallResult creates a CallResult.
func (CallResult) CorrelationID ¶
func (r CallResult) CorrelationID() uint64
CorrelationID is the value that was originally passed in the Call message.
This field is intended to be used by the function to correlate the result with the original call.
func (CallResult) DispatchID ¶
func (r CallResult) DispatchID() ID
DispatchID is the opaque identifier for the function call.
func (CallResult) Equal ¶
func (r CallResult) Equal(other CallResult) bool
Equal is true if the call result is equal to another.
func (CallResult) Error ¶
func (r CallResult) Error() (Error, bool)
Error is the error that occurred during execution of the function.
It is valid to have both an output and an error, in which case the output might contain a partial result.
func (CallResult) Output ¶
func (r CallResult) Output() (Any, bool)
Output is output from the function.
func (CallResult) String ¶
func (r CallResult) String() string
String is the string representation of the function call result.
func (CallResult) With ¶
func (r CallResult) With(opts ...CallResultOption) CallResult
With creates a copy of the CallResult with additional options applied.
type CallResultOption ¶
type CallResultOption interface {
// contains filtered or unexported methods
}
CallResultOption configures a CallResult.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error that occurred during execution of a function.
func NewErrorMessage ¶
func NewErrorMessage(typ, message string, opts ...ErrorOption) Error
NewErrorMessage creates an Error.
func (Error) Traceback ¶
Traceback is the encoded stack trace for the error.
The format is language-specific, encoded in the standard format used by each programming language to represent stack traces. Not all languages have stack traces for errors, so in some cases the value might be omitted.
type ErrorOption ¶
type ErrorOption func(*Error)
ErrorOption configures an Error.
func ErrorValue ¶
func ErrorValue(value []byte) ErrorOption
ErrorValue sets the language-specific representation of the error.
func Traceback ¶
func Traceback(traceback []byte) ErrorOption
Traceback sets the encoded stack trace for the error.
type Exit ¶
type Exit struct {
// contains filtered or unexported fields
}
Exit is a directive that terminates a function call.
func (Exit) Result ¶
func (e Exit) Result() (CallResult, bool)
Result is the function call result the exit directive carries.
type ExitOption ¶
type ExitOption interface {
// contains filtered or unexported methods
}
ExitOption configures an Exit directive.
type FunctionMap ¶
FunctionMap is a map of Dispatch functions.
type Poll ¶
type Poll struct {
// contains filtered or unexported fields
}
Poll is a general purpose directive used to spawn function calls and wait for their results, and/or to implement sleep/timer functionality.
func NewPoll ¶
func NewPoll(minResults, maxResults int, maxWait time.Duration, opts ...PollOption) Poll
NewPoll creates a Poll directive.
func (Poll) CoroutineState ¶
CoroutineState is a snapshot of the function's state.
It's passed back in the PollResult when the function is resumed.
func (Poll) MaxResults ¶
MaxResults is the maximum number of call results to deliver in the PollResult.
func (Poll) MaxWait ¶
MaxWait is the maximum amount of time the function should be suspended for while waiting for call results.
func (Poll) MinResults ¶
MinResults is the minimum number of call results to wait for before the function is resumed.
The function will be suspended until either MinResults are available, or the MaxWait timeout is reached, whichever comes first.
func (Poll) Result ¶
func (p Poll) Result() PollResult
Result creates a result for the Poll directive, that carries the same coroutine state.
type PollOption ¶
type PollOption interface {
// contains filtered or unexported methods
}
PollOption configures a Poll directive.
type PollResult ¶
type PollResult struct {
// contains filtered or unexported fields
}
PollResult is the result of a poll operation.
func NewPollResult ¶
func NewPollResult(opts ...PollResultOption) PollResult
NewPollResult creates a PollResult
func (PollResult) Clone ¶
func (r PollResult) Clone() PollResult
Clone creates a copy of the result.
func (PollResult) CoroutineState ¶
func (r PollResult) CoroutineState() Any
CoroutineState is the state recorded when the function was suspended while polling.
func (PollResult) Equal ¶
func (r PollResult) Equal(other PollResult) bool
Equal is true if the poll result is equal to another.
func (PollResult) Error ¶
func (r PollResult) Error() (Error, bool)
Error is an error that occured while processing a Poll directive.
An error indicates that none of the calls were dispatched, and must be resubmitted after the error cause has been resolved.
func (PollResult) Results ¶
func (r PollResult) Results() []CallResult
Results are the function call results attached to the poll result.
func (PollResult) String ¶
func (r PollResult) String() string
String is the string representation of the poll result.
func (PollResult) With ¶
func (r PollResult) With(opts ...PollResultOption) PollResult
With creates a copy of the PollResult with additional options applied.
type PollResultOption ¶
type PollResultOption interface {
// contains filtered or unexported methods
}
PollResultOption configures a PollResult.
func CallResults ¶
func CallResults(results ...CallResult) PollResultOption
CallResults sets the call results for the poll operation.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a request from Dispatch to run a function.
The Request carries a "directive", to either start execution with input (Input), or to resume execution with the results of a previous Response directive (e.g. PollResult).
func NewRequest ¶
func NewRequest(function string, opts ...RequestOption) Request
NewRequest creates a Request.
func (Request) CreationTime ¶
CreationTime is the creation time of the function call.
func (Request) DispatchID ¶
DispatchID is the opaque identifier for the function call.
func (Request) ExpirationTime ¶
ExpirationTime is the expiration time of the function call.
func (Request) Input ¶
Input is input to the function, along with a boolean flag that indicates whether the request carries a directive to start the function with the input.
func (Request) ParentID ¶
ParentID is the opaque identifier for the parent function call.
Functions can call other functions via Poll. If this function call has a parent function call, the identifier of the parent can be found here. If the function call does not have a parent, the field will be empty.
func (Request) PollResult ¶
func (r Request) PollResult() (PollResult, bool)
PollResult is the poll result, along with a boolean flag that indicates whether the request carries a directive to resume a function with poll results.
func (Request) RootID ¶
RootID is the opaque identifier for the root function call.
When functions call other functions, an additional level on the call hierarchy tree is created. This field carries the identifier of the root function call in the tree.
func (Request) With ¶
func (r Request) With(opts ...RequestOption) Request
With creates a copy of the Request with additional options applied.
type RequestOption ¶
type RequestOption interface {
// contains filtered or unexported methods
}
RequestOption configures a Request.
func CreationTime ¶
func CreationTime(timestamp time.Time) RequestOption
CreationTime sets the creation time for the function call.
func ExpirationTime ¶
func ExpirationTime(timestamp time.Time) RequestOption
ExpirationTime sets the expiration time for the function call.
func ParentDispatchID ¶
func ParentDispatchID(id ID) RequestOption
ParentDispatchID sets the opaque identifier of the parent function call.
func RootDispatchID ¶
func RootDispatchID(id ID) RequestOption
ParentDispatchID sets the opaque identifier of the root function call.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a response to Dispatch after a function has run.
The Response carries a "directive" to either terminate execution (Exit), or to suspend the function while waiting and/or performing operations on the Dispatch side (e.g. Poll).
func NewResponse ¶
func NewResponse(opts ...ResponseOption) Response
NewResponse creates a Response.
func NewResponseError ¶
NewResponseError creates a Response from the specified error.
func NewResponseErrorf ¶
NewResponseErrorf creates a Response from the specified error message and args.
func (Response) Result ¶
func (r Response) Result() (CallResult, bool)
Result is the result from the exit directive on the response.
func (Response) With ¶
func (r Response) With(opts ...ResponseOption) Response
With creates a copy of the Response with additional options applied.
type ResponseOption ¶
type ResponseOption interface {
// contains filtered or unexported methods
}
ResponseOption configures a Response.
type Status ¶
type Status int
Status categorizes the success or failure conditions resulting from an execution request.
func ErrorStatus ¶
ErrorStatus categorizes an error to return a Status code.
type StatusError ¶
type StatusError Status
StatusError is a Status as an error.
func (StatusError) Error ¶
func (e StatusError) Error() string
func (StatusError) Status ¶
func (e StatusError) Status() Status