server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthDigest an identifier for HTTP digest access authentication.
	AuthDigest = "digest"
	// AuthNone an identifier for no HTTP authentication.
	AuthNone = "none"
)

Variables

View Source
var Config struct {
	// LogLevel controls how verbose the levels are. Supported values: trace,
	// debug, info, warn, error, fatal, panic.
	LogLevel string `env:"LOG_LEVEL, default=info"`

	// Host is the host name or IP address used by the simulator to accept
	// connection requests. If no value is provided it will be automatically
	// resolved.
	Host string `env:"API_HOST"`

	// Port defines the port number used by the simulator to accept connection
	// requests.
	Port uint16 `env:"API_PORT, default=7547"`

	// SerialNumber will overwrite the DeviceInfo.SerialNumber datamodel
	// parameter value.
	SerialNumber string `env:"SERIAL_NUMBER, required"`

	// DataModelPath must point to a datamodel file in CSV format.
	DataModelPath string `env:"DATAMODEL_PATH, required"`

	// StateFilePath points to the state file. If the file doesn't exist it will
	// be created and will maintain all changes made to the datamodel. Missing
	// state file will trigger a BOOTSTRAP inform event.
	StateFilePath string `env:"STATE_PATH, default=state.json"`

	// ACSURL is the URL for the ACS.
	ACSURL string `env:"ACS_URL, required"`

	// ACSAuth configures authentication scheme for the ACS. It defaults to
	// "none". Supported values: digest, none
	ACSAuth string `env:"ACS_AUTH, default=none"`

	// ACSUsername is used to authenticate requests to the ACS.
	ACSUsername string `env:"ACS_USERNAME"`

	// ACSPassword is used to authenticate requests to the ACS.
	ACSPassword string `env:"ACS_PASSWORD"`

	// ACSVerifyTLS when set to false ignores certificate errors when connecting
	// to the ACS.
	ACSVerifyTLS bool `env:"ACS_VERIFY_TLS, default=false"`

	// NormalizeParameters when set to true will attempt to normalize datamodel
	// parameter types and values in order to bring them closer to the spec.
	NormalizeParameters bool `env:"NORMALIZE_PARAMETERS, default=false"`

	// RebootDelay defines how long the simulator should wait and drop incoming
	// connection requests to pretend that it reboots.
	RebootDelay time.Duration `env:"REBOOT_DELAY, default=5s"`

	// UpgradeDelay defines how long the simulator should wait and drop incoming
	// connection requests to pretend that software upgrades take time.
	UpgradeDelay time.Duration `env:"UPGRADE_DELAY, default=15s"`

	// ConnectionTimeout defines how long it can take to establish a TCP
	// connection with the ACS.
	ConnectionTimeout time.Duration `env:"CONNECTION_TIMEOUT, default=5s"`

	// RequestTimeout defines how long request processing could take.
	RequestTimeout time.Duration `env:"REQUEST_TIMEOUT, default=5s"`
}

Config is a global configuration store.

View Source
var ErrNoCreds = errors.New("username/password missing")

ErrNoCreds is returned when ACS authentication is configured for digest access authentication but no credentials are provided.

Functions

func LoadConfig

func LoadConfig(ctx context.Context) error

LoadConfig attempts to load configuration from environment variables.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a server that can connect to an ACS and receive connection requests.

func New

func New(dm *datamodel.DataModel) *Server

New creates a new server instance.

func NewWithMetrics added in v0.2.1

func NewWithMetrics(dm *datamodel.DataModel, m *metrics.Metrics) *Server

func (*Server) Inform

func (s *Server) Inform(ctx context.Context)

Inform initiates an inform message to the ACS. nolint:gocyclo

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the server.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops the server.

func (*Server) URL

func (s *Server) URL() string

URL returns the URL of the server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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