service

package
v5.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectorCaller

type ConnectorCaller interface {
	// contains filtered or unexported methods
}

ConnectorCaller is an interface to call a connector (mockable)

type ConnectorService

type ConnectorService struct {
	Definition
	ConnectorCaller
}

func NewConnectorService

func NewConnectorService(definition Definition) *ConnectorService

NewConnectorService creates a new connector service (with http connector caller)

func (*ConnectorService) GetDefinition

func (c *ConnectorService) GetDefinition() *Definition

GetDefinition returns the definition of the connector

func (*ConnectorService) GetStatus

func (c *ConnectorService) GetStatus() Status

GetStatus returns the status of the connector

func (*ConnectorService) Reload

func (c *ConnectorService) Reload(component string) (int, error)

Reload reloads the connector

func (*ConnectorService) Restart

func (c *ConnectorService) Restart() (int, error)

Restart restarts the connector

type Definition

type Definition struct {
	Id          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Url         string    `json:"-"`
	Key         string    `json:"-"`
	Type        string    `json:"type"`
	Components  []string  `json:"components"`
	LastRestart time.Time `json:"lastRestart"`
	LastReload  time.Time `json:"lastReload"`
}

func (Definition) HasComponent

func (d Definition) HasComponent(component string) bool

HasComponent checks whether definition contains given component

type Manager

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

func NewManager

func NewManager() *Manager

func (Manager) Get

func (m Manager) Get(id uuid.UUID) (Service, bool)

Get returns a service by its name

func (Manager) GetAll

func (m Manager) GetAll() (services []Service)

GetAll returns all services

func (Manager) LoadConnectors

func (m Manager) LoadConnectors() error

LoadConnectors loads the connectors from the config and register them

func (Manager) LoadPlugins

func (m Manager) LoadPlugins(core *plugin.Core) error

LoadPlugins loads the plugins from the config and register them

func (Manager) Register

func (m Manager) Register(service Service)

Register adds a service to the manager

type PluginService

type PluginService struct {
	Definition
	plugin.MyrteaPlugin
}

func (*PluginService) GetDefinition

func (p *PluginService) GetDefinition() *Definition

GetDefinition returns the definition of the service

func (*PluginService) GetStatus

func (p *PluginService) GetStatus() Status

func (*PluginService) Reload

func (p *PluginService) Reload(component string) (int, error)

Reload reloads the service

func (*PluginService) Restart

func (p *PluginService) Restart() (int, error)

Restart restarts the service

type Service

type Service interface {
	GetStatus() Status
	Reload(component string) (int, error)
	GetDefinition() *Definition
	Restart() (int, error)
}

type Status

type Status struct {
	IsAlive bool `json:"alive"`
}

Jump to

Keyboard shortcuts

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