jsonpbserializer

package
v0.0.0-...-8e6450d Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jsonpbserializer implements a fsm.StateSerializer that uses jsonpb as the underlying JSON serializer, rather than stdlibs. This is used for providing consistent serialization of types generated by the protobuf compiler. If a type that is not a proto.Message is used, it will fall through to an alternate serializer.

Package jsonpbserializer is a generated protocol buffer package.

It is generated from these files:

test.proto

It has these top-level messages:

TestMessage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPBStateSerializer

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

JSONPBStateSerializer is a StateSerializer that uses protobuf json serialization.

func New

func New(marshaler *jsonpb.Marshaler, unmarshaler *jsonpb.Unmarshaler, fallback swfsm.StateSerializer) *JSONPBStateSerializer

New creates a new JSONPBStateSerializer with the passed in marshaler, unmarshaler and fallback Serializer for non proto.Message types

func NewWithDefaults

func NewWithDefaults() *JSONPBStateSerializer

NewWithDefaults creates a new JSONPBStateSerializer with a default jsonpb.Marshaler and jsonpb.Unmarshaler. It uses a swfsm.JSONStateSerializer as the fallback serializer for non-proto.Message types

func (JSONPBStateSerializer) Deserialize

func (j JSONPBStateSerializer) Deserialize(serialized string, state interface{}) error

Deserialize unmarshalls the given (json) string into the given state. If it's a proto.Message it will use the jsonpb Marshaler, otherwise it will use the fallback

func (JSONPBStateSerializer) Serialize

func (j JSONPBStateSerializer) Serialize(state interface{}) (string, error)

Serialize serializes the given state to a json string. If it's a proto.Message it will use the jsonpb Marshaler, otherwise it will use the fallback

type TestMessage

type TestMessage struct {
	Item1 string `protobuf:"bytes,1,opt,name=Item1,json=item1" json:"Item1,omitempty"`
	Item2 string `protobuf:"bytes,2,opt,name=Item2,json=item2" json:"Item2,omitempty"`
}

func (*TestMessage) Descriptor

func (*TestMessage) Descriptor() ([]byte, []int)

func (*TestMessage) ProtoMessage

func (*TestMessage) ProtoMessage()

func (*TestMessage) Reset

func (m *TestMessage) Reset()

func (*TestMessage) String

func (m *TestMessage) String() string

Jump to

Keyboard shortcuts

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