message

package
v0.0.0-...-afdc2d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(m Message) ([]byte, error)

MarshalJSON encodes m to Protobuf JSON representation.

func Unmarshal

func Unmarshal(m Message, data []byte, gm GRPCConvertedMessage) error

Unmarshal decodes m from its Protobuf binary representation via related gRPC message.

gm should be tof the same type as the m.ToGRPCMessage() return.

func UnmarshalJSON

func UnmarshalJSON(m Message, data []byte, gm any) error

UnmarshalJSON decodes m from its Protobuf JSON representation via related gRPC message.

gm should be tof the same type as the m.ToGRPCMessage() return.

Types

type ErrUnexpectedMessageType

type ErrUnexpectedMessageType struct {
	// contains filtered or unexported fields
}

ErrUnexpectedMessageType is an error that is used to indicate message mismatch.

func NewUnexpectedMessageType

func NewUnexpectedMessageType(act, exp any) ErrUnexpectedMessageType

NewUnexpectedMessageType initializes an error about message mismatch between act and exp.

func (ErrUnexpectedMessageType) Error

func (e ErrUnexpectedMessageType) Error() string

type GRPCConvertedMessage

type GRPCConvertedMessage interface {
	UnmarshalProtobuf([]byte) error
}

GRPCConvertedMessage is an interface of the gRPC message that is used for Message encoding/decoding.

type Message

type Message interface {
	// Must return gRPC message that can
	// be used for gRPC protocol transmission.
	ToGRPCMessage() grpc.Message

	// Must restore the message from related
	// gRPC message.
	//
	// If gRPC message is not a related one,
	// ErrUnexpectedMessageType can be returned
	// to indicate this.
	FromGRPCMessage(grpc.Message) error
}

Message represents raw Protobuf message that can be transmitted via several transport protocols.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL