msg

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package msg defines the canonical message envelope that flows through queues, HTTP wire formats, and CEL filters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecodeInfo

type DecodeInfo struct {
	Status   string   `json:"status"`
	Complete bool     `json:"complete"`
	Fallback bool     `json:"fallback,omitempty"`
	Missing  []string `json:"missing,omitempty"`
}

type Envelope

type Envelope struct {
	Seq              int64                               `json:"id,omitempty"`
	ConnectorID      string                              `json:"connector,omitempty"`
	PGN              uint32                              `json:"pgn"`
	Source           uint8                               `json:"source"`
	Dest             uint8                               `json:"dest"`
	Priority         uint8                               `json:"priority"`
	Timestamp        time.Time                           `json:"timestamp"`
	ObservedAt       time.Time                           `json:"observed_at"`
	Ingress          string                              `json:"ingress,omitempty"`
	OriginIngress    string                              `json:"origin_ingress,omitempty"`
	DeviceName       *uint64                             `json:"device_name,omitempty"`
	DeviceNameHex    string                              `json:"device_name_hex,omitempty"`
	PGNName          string                              `json:"pgn_name,omitempty"`
	Variant          string                              `json:"variant,omitempty"`
	Transport        string                              `json:"transport,omitempty"`
	ManufacturerCode *uint16                             `json:"manufacturer_code,omitempty"`
	Decode           DecodeInfo                          `json:"decode"`
	Physical         map[string]n2kcatalog.PhysicalField `json:"physical,omitempty"`
	Payload          json.RawMessage                     `json:"payload"`
	Raw              []byte                              `json:"raw,omitempty"`
	// contains filtered or unexported fields
}

func FromPGN

func FromPGN(m pgn.Message) (*Envelope, error)

FromPGN converts a decoded n2k message into an Envelope. Known PGNs get their payload marshaled to JSON and Raw set to the canonical re-encoding; UnknownPGN keeps its original bytes and a null payload.

func (*Envelope) Info

func (e *Envelope) Info() pgn.MessageInfo

Info rebuilds the MessageInfo for encoding this envelope back onto a CAN bus.

func (*Envelope) PayloadMap

func (e *Envelope) PayloadMap() map[string]any

PayloadMap returns the payload as a map for CEL evaluation, decoded once and cached. Callers must treat the returned map as read-only — it is shared across all subscribers of this envelope.

func (*Envelope) SizeBytes

func (e *Envelope) SizeBytes() int

SizeBytes approximates the stored size for buffer byte-limit accounting.

Jump to

Keyboard shortcuts

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