server

package
v2.0.0-beta.22 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "server"

PluginName for the server

View Source
const RR_RELAY = "RR_RELAY" //nolint:golint,stylecheck

RR_RELAY env variable key (internal)

View Source
const RR_RPC = "RR_RPC" //nolint:golint,stylecheck

RR_RPC env variable key (internal) if the RPC presents

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Server config section
	Server struct {
		// Command to run as application.
		Command string `mapstructure:"command"`
		// User to run application under.
		User string `mapstructure:"user"`
		// Group to run application under.
		Group string `mapstructure:"group"`
		// Env represents application environment.
		Env Env `mapstructure:"env"`
		// Relay defines connection method and factory to be used to connect to workers:
		// "pipes", "tcp://:6001", "unix://rr.sock"
		// This config section must not change on re-configuration.
		Relay string `mapstructure:"relay"`
		// RelayTimeout defines for how long socket factory will be waiting for worker connection. This config section
		// must not change on re-configuration. Defaults to 60s.
		RelayTimeout time.Duration `mapstructure:"relay_timeout"`
	} `mapstructure:"server"`

	// we just need to know if the section exist, we don't need to read config from it
	RPC *struct {
		Listen string `mapstructure:"listen"`
	} `mapstructure:"rpc"`
	Logs *struct {
	} `mapstructure:"logs"`
	HTTP *struct {
	} `mapstructure:"http"`
	Redis *struct {
	} `mapstructure:"redis"`
	Boltdb *struct {
	} `mapstructure:"boltdb"`
	Memcached *struct {
	} `mapstructure:"memcached"`
	Memory *struct {
	} `mapstructure:"memory"`
	Metrics *struct {
	} `mapstructure:"metrics"`
	Reload *struct {
	} `mapstructure:"reload"`
}

All config (.rr.yaml) For other section use pointer to distinguish between `empty` and `not present`

func (*Config) InitDefaults

func (cfg *Config) InitDefaults()

InitDefaults for the server config

type Env

type Env map[string]string

Env variables type alias

type Plugin

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

Plugin manages worker

func (*Plugin) CmdFactory

func (server *Plugin) CmdFactory(env Env) (func() *exec.Cmd, error)

CmdFactory provides worker command factory associated with given context.

func (*Plugin) Init

func (server *Plugin) Init(cfg config.Configurer, log logger.Logger) error

Init application provider.

func (*Plugin) Name

func (server *Plugin) Name() string

Name contains service name.

func (*Plugin) NewWorker

func (server *Plugin) NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (*worker.Process, error)

NewWorker issues new standalone worker.

func (*Plugin) NewWorkerPool

func (server *Plugin) NewWorkerPool(ctx context.Context, opt pool.Config, env Env, listeners ...events.Listener) (pool.Pool, error)

NewWorkerPool issues new worker pool.

func (*Plugin) Serve

func (server *Plugin) Serve() chan error

Serve (Start) server plugin (just a mock here to satisfy interface)

func (*Plugin) Stop

func (server *Plugin) Stop() error

Stop used to close chosen in config factory

type Server

type Server interface {
	CmdFactory(env Env) (func() *exec.Cmd, error)
	NewWorker(ctx context.Context, env Env, listeners ...events.Listener) (*worker.Process, error)
	NewWorkerPool(ctx context.Context, opt pool.Config, env Env, listeners ...events.Listener) (pool.Pool, error)
}

Server creates workers for the application.

Jump to

Keyboard shortcuts

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