yggdrasil – github.com/redhatinsights/yggdrasil Index | Files | Directories

package yggdrasil

import "github.com/redhatinsights/yggdrasil"

Index

Functions

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns an appropriate path to a config file. If the created path does not exist, an empty string is returned.

Types

type Command

type Command struct {
	Command   CommandName       `json:"command"`
	Arguments map[string]string `json:"arguments"`
}

A Command message is published by the server on the "control" topic when it needs to instruct a client to perform an operation.

type CommandName

type CommandName string

CommandName represents accepted values for the "command" field of Command messages.

const (
	// CommandNameReconnect instructs a client to temporarily disconnect and
	// reconnect to the broker.
	CommandNameReconnect CommandName = "reconnect"

	// CommandNamePing instructs a client to respond with a "pong" event.
	CommandNamePing CommandName = "ping"

	// CommandNameDisconnect instructs a client to permanently disconnect.
	CommandNameDisconnect CommandName = "disconnect"

	// CommandNameCancel instructs a client to cancel a previous message.
	CommandNameCancel CommandName = "cancel"
)

type ConnectionState

type ConnectionState string

ConnectionState represents accepted values for the "state" field of ConnectionStatus messages.

const (
	// ConnectionStateOnline indicates a client is online and subscribing to
	// topics.
	ConnectionStateOnline ConnectionState = "online"

	// ConnectionStateOffline indicates a client is no longer online.
	ConnectionStateOffline ConnectionState = "offline"
)

type ConnectionStatus

type ConnectionStatus struct {
	Type       MessageType `json:"type"`
	MessageID  string      `json:"message_id"`
	ResponseTo string      `json:"response_to"`
	Version    int         `json:"version"`
	Sent       time.Time   `json:"sent"`
	Content    struct {
		CanonicalFacts map[string]interface{}       `json:"canonical_facts"`
		Dispatchers    map[string]map[string]string `json:"dispatchers"`
		State          ConnectionState              `json:"state"`
		Tags           map[string]string            `json:"tags,omitempty"`
		ClientVersion  string                       `json:"client_version,omitempty"`
	} `json:"content"`
}

A ConnectionStatus message is published by the client when it connects to the broker. The message is expected to be published as a retained message and its presence is considered an acceptable way to decide whether a client is active and functioning normally.

type Control

type Control struct {
	Type       MessageType     `json:"type"`
	MessageID  string          `json:"message_id"`
	ResponseTo string          `json:"response_to"`
	Version    int             `json:"version"`
	Sent       time.Time       `json:"sent"`
	Content    json.RawMessage `json:"content"`
}

type Data

type Data struct {
	Type       MessageType       `json:"type"`
	MessageID  string            `json:"message_id"`
	ResponseTo string            `json:"response_to"`
	Version    int               `json:"version"`
	Sent       time.Time         `json:"sent"`
	Directive  string            `json:"directive"`
	Metadata   map[string]string `json:"metadata"`
	Content    json.RawMessage   `json:"content"`
}

Data messages are published by both client and server on their respective "data" topic. The client consumes Data messages and routes them to an appropriate worker based on the "Directive" field.

type Event

type Event struct {
	Type       MessageType `json:"type"`
	MessageID  string      `json:"message_id"`
	ResponseTo string      `json:"response_to"`
	Version    int         `json:"version"`
	Sent       time.Time   `json:"sent"`
	Content    string      `json:"content"`
}

An Event message is published by the client on the "control" topic when it wishes to inform the server that a notable event occurred.

type EventName

type EventName string

EventName represents accepted values for the "event" field of an Event message.

const (
	// EventNameDisconnect informs the server that the client will disconnect.
	EventNameDisconnect EventName = "disconnect"

	// EventNamePong informs the server that the client has received a "ping"
	// command.
	EventNamePong EventName = "pong"
)

type MessageType

type MessageType string

MessageType represents accepted values in the "type" field of messages.

const (
	MessageTypeConnectionStatus MessageType = "connection-status"
	MessageTypeCommand          MessageType = "command"
	MessageTypeEvent            MessageType = "event"
	MessageTypeData             MessageType = "data"
)

The supported message types.

type Response

type Response struct {
	Code     int               `json:"code"`
	Metadata map[string]string `json:"metadata"`
	Data     []byte            `json:"data"`
}

Response messages are published by the server as a response to a data message. This is most often used as a receipt to indicate the reception of a message by a synchronous request/response transport (such as the HTTP polling transport).

type WorkerMessage

type WorkerMessage struct {
	MessageID   string    `json:"message_id"`
	Sent        time.Time `json:"sent"`
	WorkerName  string    `json:"worker_name"`
	ResponseTo  string    `json:"response_to"`
	WorkerEvent struct {
		EventName uint              `json:"event_name"`
		EventData map[string]string `json:"event_data"`
	}
}

A WorkerMessage represents the structure of a journal entry in the optional message journal. These worker messages are created when the dispatcher receives emitted worker event data and when data is dispatched to a worker.

Source Files

messages.go util.go

Directories

PathSynopsis
cmd
cmd/yggctl
cmd/yggd
dbus
internal
ipc
worker
worker/echo
Version
v0.4.5 (latest)
Published
Feb 3, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
3 weeks ago

Tools for package owners.