receptor

package module
v0.0.0-...-a9562c4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SERVICE_STOP_TIMEOUT = 5 * time.Second // Timeout for EACH service to cleanup
	PLUGIN_STOP_TIMEOUT  = 5 * time.Second // Timeout for EACH plugin process to cleanup
)

Functions

This section is empty.

Types

type ActorConfig

type ActorConfig struct {
	Type   string          `json:"type"`
	Config json.RawMessage `json:"cfg"`
}

type Config

type Config struct {
	Services map[string]ServiceConfig   `json:"services"`
	Watchers map[string]json.RawMessage `json:"watchers"`
	Reactors map[string]json.RawMessage `json:"reactors"`
}

func NewConfigFromFile

func NewConfigFromFile(filename string) (*Config, error)

type Receptor

type Receptor struct {
	Services     []*Service
	PluginLookup plugin.LookupService
	DoneCh       chan struct{} // Is closed if all service components are shut down
	FailureCh    chan struct{} // Is closed if a service fails
}

func NewReceptor

func NewReceptor(lookup plugin.LookupService) *Receptor

func (*Receptor) Init

func (r *Receptor) Init(cfg *Config) error

func (*Receptor) Setup

func (r *Receptor) Setup(cfg *Config) ([]*Service, error)

Setup sets up all services defined by config.

func (*Receptor) SetupGlobalConfig

func (r *Receptor) SetupGlobalConfig(cfg *Config) error

SetupGlobalConfig configures watchers and reactors with their global config. Only setup watchers/reactors used by services.

func (*Receptor) SetupReactor

func (r *Receptor) SetupReactor(cfg ActorConfig) (pipe.Endpoint, error)

SetupReactor registers a reactor with the service specific config.

func (*Receptor) SetupService

func (r *Receptor) SetupService(name string, cfg ServiceConfig) (*Service, error)

SetupService sets up all watchers and reactors of the service with their service specific configuration.

func (*Receptor) SetupServices

func (r *Receptor) SetupServices(serviceCfgs map[string]ServiceConfig) ([]*Service, error)

SetupServices sets up multiple services and their components defined by their service config.

func (*Receptor) SetupWatcher

func (r *Receptor) SetupWatcher(cfg ActorConfig) (pipe.Endpoint, error)

SetupWatcher registers a watcher with the service specific config.

func (*Receptor) Start

func (r *Receptor) Start()

func (*Receptor) Stop

func (r *Receptor) Stop()

Stop stops all registered services and blocks until all stopped or reached timeout.

type Service

type Service struct {
	DoneCh    chan struct{} // Is closed if all service components are shut down
	FailureCh chan struct{} // Is closed if a failure occurs
	// contains filtered or unexported fields
}

func NewService

func NewService(name string) *Service

func (*Service) AddReactorEndpoint

func (s *Service) AddReactorEndpoint(name string, endpoint *pipe.ManagedEndpoint)

func (*Service) AddWatcherEndpoint

func (s *Service) AddWatcherEndpoint(name string, endpoint *pipe.ManagedEndpoint)

func (*Service) Name

func (s *Service) Name() string

func (*Service) Shutdown

func (s *Service) Shutdown()

Shutdown sends a stop signal to all watchers and reactors. Does not block.

func (*Service) Start

func (s *Service) Start()

Start starts the service. It creates a pipe between all watchers and reactors and starts them, does not block.

func (*Service) Stop

func (s *Service) Stop(timeout time.Duration)

Stop stops the service and all its watchers and reactors. Blocks until all components are stopped or reach timeout. Closes service doneCh channel.

type ServiceConfig

type ServiceConfig struct {
	// Map unique user-defined name to actor config
	Watchers map[string]ActorConfig `json:"watchers"`
	Reactors map[string]ActorConfig `json:"reactors"`
}

Jump to

Keyboard shortcuts

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