Documentation
¶
Index ¶
- func NewLazyStreamVisitor(streamMessage proto.Message) func() *StreamVisitor
- type EOFCallback
- type InvalidTransitionCallback
- type MessageCallback
- type Stream
- type StreamVisitor
- type StreamVisitorOption
- func WithCallback(transitionTo protoreflect.FieldNumber, cb MessageCallback) StreamVisitorOption
- func WithEOFCallback(cb EOFCallback) StreamVisitorOption
- func WithNotExpectingToGet(code codes.Code, transitionTo ...protoreflect.FieldNumber) StreamVisitorOption
- func WithStartState(startState protoreflect.FieldNumber) StreamVisitorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLazyStreamVisitor ¶
func NewLazyStreamVisitor(streamMessage proto.Message) func() *StreamVisitor
Types ¶
type EOFCallback ¶
type EOFCallback func() error
type InvalidTransitionCallback ¶
type InvalidTransitionCallback func(from, to protoreflect.FieldNumber, allowed []protoreflect.FieldNumber, message proto.Message) error
InvalidTransitionCallback is a callback that is called when an invalid transition is attempted. 'message' is nil when 'to' is eofState.
type MessageCallback ¶
type MessageCallback any
MessageCallback is a function with signature func(message someConcreteProtoMessage) error someConcreteProtoMessage must be the type passed to NewStreamVisitor().
type StreamVisitor ¶
type StreamVisitor struct {
// contains filtered or unexported fields
}
StreamVisitor allows to consume messages in a gRPC stream. Message order should follow the automata, defined on fields in a oneof group.
func NewStreamVisitor ¶
func NewStreamVisitor(streamMessage proto.Message) (*StreamVisitor, error)
func (*StreamVisitor) Visit ¶
func (s *StreamVisitor) Visit(stream Stream, opts ...StreamVisitorOption) error
type StreamVisitorOption ¶
type StreamVisitorOption func(*svConfig) error
StreamVisitorOption is an option for the visitor. Must return nil or an error, compatible with the gRPC status package.
func WithCallback ¶
func WithCallback(transitionTo protoreflect.FieldNumber, cb MessageCallback) StreamVisitorOption
WithCallback registers cb to be called when entering transitionTo when parsing the stream. Only one callback can be registered per target
func WithEOFCallback ¶
func WithEOFCallback(cb EOFCallback) StreamVisitorOption
WithEOFCallback sets a callback for end of stream.
func WithNotExpectingToGet ¶
func WithNotExpectingToGet(code codes.Code, transitionTo ...protoreflect.FieldNumber) StreamVisitorOption
WithNotExpectingToGet is used to list fields that the caller is not expecting to get during this Visit() invocation.
func WithStartState ¶
func WithStartState(startState protoreflect.FieldNumber) StreamVisitorOption
WithStartState allows to specify a custom automata start state. The visitor then acts as if it has just visited field with startState number.