config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StdIn  string = "stdin"
	StdOut string = "stdout"
)

Variables

This section is empty.

Functions

func ApplyConfigurationFromFile

func ApplyConfigurationFromFile(filepath string)

Entry point to read in the provided file, resolve the connections, readers and writers and apply the configuration

Types

type Config

type Config struct {
	Connections []ConfigConnection
	Nodes       ConfigNodes
	Settings    ConfigSettings

	Conns []Connection `json:"-"`
	// contains filtered or unexported fields
}

func (Config) Close

func (c Config) Close() error

Close all provided reader and writers Only the "first" occurring error will be returned, writers are closed first.

func (*Config) Initialise

func (c *Config) Initialise() error

type ConfigConnection

type ConfigConnection struct {
	ReaderID string
	WriterID string
}

type ConfigFile

type ConfigFile struct {
	ID   string
	Path string
	// Determines whether this file is in truncate mode or append mode. By default this is false
	// meaning it is in append mode.
	Trunc bool
	// contains filtered or unexported fields
}

func (ConfigFile) GetID

func (c ConfigFile) GetID() string

[ConfigModel.GetID]

func (ConfigFile) Reader

func (c ConfigFile) Reader() (io.ReadCloser, error)

[ConfigModel.Reader]

func (ConfigFile) Validate

func (c ConfigFile) Validate() error

[ConfigModel.Validate]

func (ConfigFile) Writer

func (c ConfigFile) Writer() (io.WriteCloser, error)

[ConfigModel.Writer]

type ConfigIPC

type ConfigIPC struct {
	ID      string
	Channel string
}

func (ConfigIPC) GetID

func (c ConfigIPC) GetID() string

[ConfigModel.GetID]

func (ConfigIPC) Reader

func (c ConfigIPC) Reader() (io.ReadCloser, error)

[ConfigModel.Reader]

func (ConfigIPC) Validate

func (c ConfigIPC) Validate() error

[ConfigModel.Validate]

func (ConfigIPC) Writer

func (c ConfigIPC) Writer() (io.WriteCloser, error)

[ConfigModel.Writer]

type ConfigModel

type ConfigModel interface {
	// GetID returns the ID of the model
	GetID() string
	// Validate will perform any validation on behalf of the object, or any pre-setup that is required
	Validate() error
	// Reader will get a reader for the underlying configuration
	Reader() (io.ReadCloser, error)
	// Writer will get a writer for the underlying configuration
	Writer() (io.WriteCloser, error)
}

An interface that all Config* objects will implement.

type ConfigNodes

type ConfigNodes struct {
	Ports   []ConfigPort
	Files   []ConfigFile
	Sockets []ConfigSocket
	Ipcs    []ConfigIPC
}

type ConfigPort

type ConfigPort struct {
	ID      string
	Channel string
	Mode    goSerial.Mode
	// The resolved and connected port, in a scenario where we call validate
	Port        *serial.CustomPort `json:"-"`
	ReadTimeout int
}

func (ConfigPort) GetID

func (c ConfigPort) GetID() string

[ConfigModel.GetID]

func (*ConfigPort) Open

func (c *ConfigPort) Open() error

func (*ConfigPort) Reader

func (c *ConfigPort) Reader() (io.ReadCloser, error)

[ConfigModel.Reader]

func (ConfigPort) Validate

func (c ConfigPort) Validate() error

[ConfigModel.Validate]

func (*ConfigPort) Writer

func (c *ConfigPort) Writer() (io.WriteCloser, error)

[ConfigModel.Writer]

type ConfigSettings

type ConfigSettings struct {
	// Timeout in seconds
	Timeout int
}

type ConfigSocket

type ConfigSocket struct {
	ID       string
	Protocol string
	Port     uint16
	Address  string
}

func (ConfigSocket) GetID

func (c ConfigSocket) GetID() string

[ConfigModel.GetID]

func (ConfigSocket) Reader

func (c ConfigSocket) Reader() (io.ReadCloser, error)

[ConfigModel.Reader]

func (ConfigSocket) Validate

func (c ConfigSocket) Validate() error

[ConfigModel.Validate]

func (ConfigSocket) Writer

func (c ConfigSocket) Writer() (io.WriteCloser, error)

[ConfigModel.Writer]

type Connection

type Connection struct {
	Reader    io.Reader
	ReaderId  string
	Writer    io.Writer
	WriterIds []string
}

Jump to

Keyboard shortcuts

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