message

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTypeAndDataVersion

func ParseTypeAndDataVersion(data interface{}) (Type, DataVersion, error)

ParseTypeAndDataVersion returns the message type and data version for a given data The type a hyphen separated string The data should be a struct whose name is like (all those results in the same type): MyMessageV1 -> "my-message", 1 myMessageV1 -> "my-message", 1 MYMessageV1 -> "my-message", 1

Types

type DataVersion

type DataVersion int

DataVersion is the type used to represent messages data version

type Message

type Message struct {
	SchemaVersion SchemaVersion
	ID            string `json:"Id"`
	Source        Source
	Type          Type
	CreatedAt     string
	DataVersion   DataVersion
	Data          json.RawMessage
}

Message is the default event structure

func New

func New(ctx context.Context, source Source, data interface{}) (Message, error)

New creates a new message with auto discovering of message type and version The type name of the data param must be in the format <type>V<version>, like nsuReceivedV3 The data must be json marshable

func (Message) MarshalZerologObject

func (m Message) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements the zerolog marshaler so it can be logged using: log.With().EmbedObject(stakeholder).Msg("Some message")

type SchemaVersion

type SchemaVersion int

SchemaVersion is the type used to represent mesages schema version

const (
	// SchemaVersion3 is the only schema version available right now.
	// All messages are produced with this as default.
	SchemaVersion3 SchemaVersion = 3
)

type Source

type Source string

Source is the type used to represent messages source

func (Source) String

func (s Source) String() string

type Type

type Type string

Type is the type used to represent messages type

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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