config

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config defines DDA configuration types to be used programmatically or within a DDA configuration file in YAML format.

Note that the fields of all configuration types are not documented in code but solely in the default DDA YAML configuration file located in the project root folder (single source of truth).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateName

func ValidateName(name string, context ...string) error

Asserts that the given name conforms to the DDA naming convention for configuration items used as pub-sub topic fields. Such a name must be non-empty and only contain ASCII digits 0-9, lowercase letters a-z, uppercase letters A-Z, dot (.), hyphen (-), or underscore (_). Returns an error if assertion fails; nil otherwise.

This function is intended to be used by communication binding implementations.

func ValidateNonEmpty

func ValidateNonEmpty(value string, context ...string) error

Asserts that the given value is a non-empty string. Returns an error if assertion fails; nil otherwise. The given context strings are embedded into the error.

Types

type AuthOptions

type AuthOptions struct {
	Method   string
	Cert     string
	Key      string
	Verify   bool
	Username string
	Password string
}

AuthOptions defines authentication options for a selected pub-sub messaging protocol.

type Config

type Config struct {
	Version  string
	Identity Identity
	Cluster  string
	Apis     ConfigApis
	Services ConfigServices
}

A Config represents the complete hierarchy of configuration parameters for all DDA services as nested struct types that map to the underlying YAML configuration schema. It should be created with New() or ReadConfig() to ensure all fields are correctly populated.

func New

func New() *Config

New creates a Config struct pre-filled with default values as specified in the YAML DDA configuration format.

func ReadConfig

func ReadConfig(file string) (*Config, error)

ReadConfig reads and parses the given DDA configuration file in YAML format and returns a *Config on success or an error, otherwise.

func (*Config) Verify

func (c *Config) Verify() error

Verify asserts that the configuration version matches the supported configuration schema and that the Cluster name is valid. Returns an error otherwise.

type ConfigApi

type ConfigApi struct {
	Address   string
	Disabled  bool
	Keepalive time.Duration
}

A ConfigApi comprises server-side configuration options of a specific public DDA Client API.

type ConfigApis

type ConfigApis struct {
	Grpc    ConfigApi
	GrpcWeb ConfigWebApi `yaml:"grpc-web"`
	Cert    string
	Key     string
}

ConfigApis comprises server-side configuration options of all public DDA Client APIs.

type ConfigComService

type ConfigComService struct {
	Protocol string
	Url      string
	Auth     AuthOptions
	Opts     map[string]any
	Disabled bool
}

ConfigComService defines configuration options for a selected pub-sub messaging protocol.

type ConfigServices

type ConfigServices struct {
	Com   ConfigComService
	Store ConfigStoreService
	State ConfigStateService
}

ConfigServices provides configuration options for all peripheral DDA services.

type ConfigStateService added in v0.42.0

type ConfigStateService struct {
	Protocol  string
	Store     string
	Bootstrap bool
	Disabled  bool
	Opts      map[string]any
}

ConfigStateService provides configuration options for a selected consensus protocol.

type ConfigStoreService added in v0.41.0

type ConfigStoreService struct {
	Engine   string
	Location string
	Disabled bool
}

ConfigStoreService provides configuration options for a selected local key-value storage.

type ConfigWebApi

type ConfigWebApi struct {
	Address                  string
	Disabled                 bool
	AccessControlAllowOrigin []string `yaml:"access-control-allow-origin"`
}

A ConfigApi used by Web HTTP clients.

type Identity

type Identity struct {
	Name string
	Id   string
}

An Identity represents the unique identity of a DDA.

Jump to

Keyboard shortcuts

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