server

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const PluginName = "server"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Command to run as application.
	Command string

	// User to run application under.
	User string

	// Group to run application under.
	Group string

	// Env represents application environment.
	Env Env

	// Listen 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

	// 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
}

Config config combines factory, pool and cmd configurations.

func (*Config) InitDefaults

func (cfg *Config) InitDefaults()

type Env

type Env map[string]string

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 assocated 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.EventListener) (worker.BaseProcess, error)

NewWorker issues new standalone worker.

func (*Plugin) NewWorkerPool

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

NewWorkerPool issues new worker pool.

func (*Plugin) Serve

func (server *Plugin) Serve() chan error

func (*Plugin) Stop

func (server *Plugin) Stop() error

type Server

type Server interface {
	CmdFactory(env Env) (func() *exec.Cmd, error)
	NewWorker(ctx context.Context, env Env, listeners ...events.EventListener) (worker.BaseProcess, error)
	NewWorkerPool(ctx context.Context, opt poolImpl.Config, env Env, listeners ...events.EventListener) (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