Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal converts its input v into []byte using the codec, respecting RestateMarshaler implementors
Types ¶
type Codec ¶
Codec is a mechanism for serialising and deserialising a wide range of types. Care should be taken to ensure that only valid types are passed to a codec, eg proto.Message for ProtoCodec.
type InputPayload ¶
type InputPayload struct {
Required bool `json:"required"`
ContentType *string `json:"contentType,omitempty"`
JsonSchema interface{} `json:"jsonSchema,omitempty"`
}
InputPayload is provided to Restate upon handler discovery, to teach the ingress how to validate incoming request bodies.
func InputPayloadFor ¶
func InputPayloadFor(codec PayloadCodec, i any) *InputPayload
InputPayloadFor determines the InputPayload for the type stored in i, respecting RestateUnmarshaler implementors
type OutputPayload ¶
type OutputPayload struct {
ContentType *string `json:"contentType,omitempty"`
SetContentTypeIfEmpty bool `json:"setContentTypeIfEmpty"`
JsonSchema interface{} `json:"jsonSchema,omitempty"`
}
OutputPayload is provided to Restate upon handler discovery, to teach the ingress how to annotate outgoing response bodies.
func OutputPayloadFor ¶
func OutputPayloadFor(codec PayloadCodec, o any) *OutputPayload
OutputPayloadFor determines the OutputPayload for the type stored in o, respecting RestateMarshaler implementors
type PayloadCodec ¶
type PayloadCodec interface {
InputPayload(i any) *InputPayload
OutputPayload(o any) *OutputPayload
Codec
}
PayloadCodec is implemented by a Codec that can also be used in handlers, and so must provide a InputPayload and OutputPayload i and o are zero values of the input/output types, which the codec may use to influence its response.
var ( // BinaryCodec marshals []byte and unmarshals into *[]byte // In handlers, it uses a content type of application/octet-stream BinaryCodec PayloadCodec = binaryCodec{} // ProtoCodec marshals proto.Message and unmarshals into proto.Message or pointers to types that implement proto.Message // In handlers, it uses a content-type of application/proto ProtoCodec PayloadCodec = protoCodec{} // ProtoJSONCodec marshals proto.Message and unmarshals into proto.Message or pointers to types that implement proto.Message // It uses the protojson package to marshal and unmarshal // In handlers, it uses a content-type of application/json ProtoJSONCodec PayloadCodec = protoJSONCodec{} // JSONCodec marshals any json.Marshallable type and unmarshals into any json.Unmarshallable type // In handlers, it uses a content-type of application/json JSONCodec PayloadCodec = jsonCodec{} )
type RestateMarshaler ¶
type RestateMarshaler interface {
RestateMarshal(codec Codec) ([]byte, error)
OutputPayload(codec Codec) *OutputPayload
}
RestateMarshaler can be implemented by types that want to control their own marshaling
type RestateUnmarshaler ¶
type RestateUnmarshaler interface {
RestateUnmarshal(codec Codec, data []byte) error
InputPayload(codec Codec) *InputPayload
}
RestateUnmarshaler can be implemented by types that want to control their own unmarshaling
type Void ¶
type Void struct{}
Void is a placeholder to signify 'no value' where a type is otherwise needed It implements RestateMarshaler and RestateUnmarshaler to ensure that no marshaling or unmarshaling ever happens on this type.
func (Void) InputPayload ¶
func (v Void) InputPayload(codec Codec) *InputPayload
func (Void) OutputPayload ¶
func (v Void) OutputPayload(codec Codec) *OutputPayload