mptymsg

package
v0.0.0-...-52eac44 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonMarshal

func JsonMarshal[T Recordable](t T) ([]byte, error)

JsonMarshal returns the Recordable message as json bytes. To decode the value you must Register(t) first.

func Register

func Register[T Recordable](t T)

Types

type Envelope

type Envelope struct {
	Type    string
	Payload json.RawMessage
}

type EnvelopeEncode

type EnvelopeEncode struct {
	Type    string
	Payload any
}

type Recordable

type Recordable interface {
	// TypeName is used during encoding/decoding to determine what the payload
	// of each messages concrete type is. You should NOT use the golang %T as
	// that will change if you move the type to a different package.
	TypeName() string

	Ts() time.Time

	SetId(int64) Recordable
}

func JsonUnmarshal

func JsonUnmarshal(data []byte) (Recordable, error)

JsonUnmarshal will decode a Recordable message from json bytes. You must Register(t) any types at least once before attempting to decode them.

type SqliteRecorder

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

func NewSqlite

func NewSqlite(ctx context.Context, filename string) (*SqliteRecorder, error)

func (*SqliteRecorder) Close

func (r *SqliteRecorder) Close() error

func (*SqliteRecorder) Read

func (r *SqliteRecorder) Read(n int) ([]Recordable, error)

func (*SqliteRecorder) Save

func (r *SqliteRecorder) Save(msg Recordable) (Recordable, error)

Jump to

Keyboard shortcuts

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