service

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetChannel             = "get-channel"
	GetChannels            = "get-channels"
	GetConfiguration       = "get-configuration"
	GetJob                 = "get-job"
	GetJobs                = "get-jobs"
	GetJobStatus           = "get-job-status"
	GetModule              = "get-module"
	GetModules             = "get-modules"
	GetModuleActiveJob     = "get-module-active-job"
	GetModuleConfiguration = "get-module-configuration"
	GetModuleJob           = "get-module-job"
	GetModuleJobs          = "get-module-jobs"
	GetModuleProperties    = "get-module-properties"
	GetModuleProperty      = "get-module-property"
	GetModuleSettings      = "get-module-settings"
	GetModuleStatus        = "get-module-status"
	GetSettings            = "get-settings"
	GetStatus              = "get-status"
	GetUnitConfiguration   = "get-unit-configuration"
	ModuleAvailableEvents  = "module-available-events"
	ModuleCancelJob        = "module-cancel-job"
	ModuleSubmitEvent      = "module-submit-event"
	ModuleSubmitJob        = "module-submit-job"
	SetModuleProperties    = "set-module-properties"
	SetModuleProperty      = "set-module-property"
	TryModuleConnect       = "try-module-connect"
	TryModuleDisable       = "try-module-disable"
	TryModuleDisconnect    = "try-module-disconnect"
	TryModuleEnable        = "try-module-enable"
	TryModuleLoad          = "try-module-load"
	TryModuleReload        = "try-module-reload"
	TryModuleUnload        = "try-module-unload"
)
View Source
const (
	// UnexpectedResponseCode is used with validation when the response has an error
	UnexpectedResponseCode = int32(iota + 601)

	// MultipleRepliesCode is a warning code until multiple replies are handled
	MultipleRepliesCode

	// UnmarshalFailedCode should be set when response data can't be unmarshalled
	UnmarshalFailedCode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker defines a plantd broker instance.

func NewBroker

func NewBroker(config *gcontext.Config) *Broker

NewBroker creates an instance of the broker class.

func (*Broker) App

func (b *Broker) App(ctx context.Context, wg *sync.WaitGroup)

App creates a web application to serve static website content.

func (*Broker) Serve

func (b *Broker) Serve(ctx context.Context, wg *sync.WaitGroup)

Serve launches a simple REQ/REP service to handler basic messages.

func (*Broker) Start

func (b *Broker) Start(ctx context.Context, wg *sync.WaitGroup)

Start is responsible for bootstrapping the worker threads and handling shutdown.

type Client

type Client interface {
	Send(name string, request ...string) error
	Recv() ([]string, error)
}

Client interface to wrap the MDP client to be able to mock it in tests.

type Endpoint

type Endpoint interface {
	GetChannel(_ context.Context, in interface{}) (interface{}, error)
	GetChannels(_ context.Context, in interface{}) (interface{}, error)
	GetConfiguration(_ context.Context, in interface{}) (interface{}, error)
	GetJob(_ context.Context, in interface{}) (interface{}, error)
	GetJobs(_ context.Context, in interface{}) (interface{}, error)
	GetJobStatus(_ context.Context, in interface{}) (interface{}, error)
	GetModule(_ context.Context, in interface{}) (interface{}, error)
	GetModules(_ context.Context, in interface{}) (interface{}, error)
	GetModuleActiveJob(_ context.Context, in interface{}) (interface{}, error)
	GetModuleJob(_ context.Context, in interface{}) (interface{}, error)
	GetModuleJobs(_ context.Context, in interface{}) (interface{}, error)
	GetModuleProperty(_ context.Context, in interface{}) (interface{}, error)
	GetModuleProperties(_ context.Context, in interface{}) (interface{}, error)
	GetModuleSettings(_ context.Context, in interface{}) (interface{}, error)
	GetModuleStatus(_ context.Context, in interface{}) (interface{}, error)
	GetStatus(_ context.Context, in interface{}) (interface{}, error)
	GetSettings(_ context.Context, in interface{}) (interface{}, error)
	GetUnitConfiguration(_ context.Context, in interface{}) (interface{}, error)
	ModuleSubmitJob(_ context.Context, in interface{}) (interface{}, error)
	ModuleSubmitEvent(_ context.Context, in interface{}) (interface{}, error)
	ModuleAvailableEvents(_ context.Context, in interface{}) (interface{}, error)
	SetModuleProperty(_ context.Context, in interface{}) (interface{}, error)
	SetModuleProperties(_ context.Context, in interface{}) (interface{}, error)
	TryModuleConnect(_ context.Context, in interface{}) (interface{}, error)
	TryModuleDisable(_ context.Context, in interface{}) (interface{}, error)
	TryModuleLoad(_ context.Context, in interface{}) (interface{}, error)
	TryModuleReload(_ context.Context, in interface{}) (interface{}, error)
	TryModuleUnload(_ context.Context, in interface{}) (interface{}, error)
}

Endpoint interface to expose common methods to implement.

type GrpcEndpoint

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

GrpcEndpoint defines a service that handles gRPC messages.

func NewGrpcEndpoint

func NewGrpcEndpoint(name string, client *mdp.Client) (*GrpcEndpoint, error)

NewGrpcEndpoint creates an instance of the endpoint class.

func (*GrpcEndpoint) GetChannel

GetChannel <- ChannelRequest -> ChannelResponse

func (*GrpcEndpoint) GetChannels

func (e *GrpcEndpoint) GetChannels(_ context.Context, in *pb.Empty) (*pb.ChannelsResponse, error)

GetChannels <- Empty -> ChannelsResponse

func (*GrpcEndpoint) GetConfiguration

GetConfiguration <- ConfigurationRequest -> ConfigurationResponse

func (*GrpcEndpoint) GetJob

func (e *GrpcEndpoint) GetJob(_ context.Context, in *pb.JobRequest) (*pb.JobResponse, error)

GetJob <- JobRequest -> JobResponse

func (*GrpcEndpoint) GetJobStatus

func (e *GrpcEndpoint) GetJobStatus(_ context.Context, in *pb.JobRequest) (*pb.JobStatusResponse, error)

GetJobStatus <- JobRequest -> JobStatusResponse

func (*GrpcEndpoint) GetJobs

func (e *GrpcEndpoint) GetJobs(_ context.Context, in *pb.Empty) (*pb.JobsResponse, error)

GetJobs <- Empty -> JobsResponse

func (*GrpcEndpoint) GetModule

GetModule <- ModuleRequest -> ModuleResponse

func (*GrpcEndpoint) GetModuleActiveJob

func (e *GrpcEndpoint) GetModuleActiveJob(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

GetModuleActiveJob <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) GetModuleConfiguration

func (e *GrpcEndpoint) GetModuleConfiguration(_ context.Context, in *pb.ModuleRequest) (*pb.ConfigurationResponse, error)

GetModuleConfiguration <- ModuleRequest -> ConfigurationResponse

func (*GrpcEndpoint) GetModuleJob

func (e *GrpcEndpoint) GetModuleJob(_ context.Context, in *pb.ModuleJobRequest) (*pb.JobResponse, error)

GetModuleJob <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) GetModuleJobs

func (e *GrpcEndpoint) GetModuleJobs(_ context.Context, in *pb.ModuleRequest) (*pb.JobsResponse, error)

GetModuleJobs <- ModuleRequest -> JobsResponse

func (*GrpcEndpoint) GetModuleProperties

func (e *GrpcEndpoint) GetModuleProperties(_ context.Context, in *pb.PropertiesRequest) (*pb.PropertiesResponse, error)

GetModuleProperties <- PropertiesRequest -> PropertiesResponse

func (*GrpcEndpoint) GetModuleProperty

func (e *GrpcEndpoint) GetModuleProperty(_ context.Context, in *pb.PropertyRequest) (*pb.PropertyResponse, error)

GetModuleProperty <- PropertyRequest -> PropertyResponse

func (*GrpcEndpoint) GetModuleSettings

func (e *GrpcEndpoint) GetModuleSettings(_ context.Context, in *pb.ModuleRequest) (*pb.SettingsResponse, error)

GetModuleSettings <- ModuleRequest -> SettingsResponse

func (*GrpcEndpoint) GetModuleStatus

func (e *GrpcEndpoint) GetModuleStatus(_ context.Context, in *pb.ModuleRequest) (*pb.StatusResponse, error)

GetModuleStatus <- ModuleRequest -> StatusResponse

func (*GrpcEndpoint) GetModules

func (e *GrpcEndpoint) GetModules(_ context.Context, in *pb.Empty) (*pb.ModulesResponse, error)

GetModules <- Empty -> ModulesResponse

func (*GrpcEndpoint) GetSettings

GetSettings <- SettingsRequest -> SettingsResponse

func (*GrpcEndpoint) GetStatus

GetStatus <- StatusRequest -> StatusResponse

func (*GrpcEndpoint) GetUnitConfiguration

func (e *GrpcEndpoint) GetUnitConfiguration(_ context.Context, in *pb.Empty) (*pb.ConfigurationResponse, error)

GetUnitConfiguration <- Empty -> ConfigurationResponse

func (*GrpcEndpoint) ModuleAvailableEvents

func (e *GrpcEndpoint) ModuleAvailableEvents(_ context.Context, in *pb.ModuleRequest) (*pb.EventsResponse, error)

ModuleAvailableEvents <- ModuleRequest -> EventsResponse

func (*GrpcEndpoint) ModuleCancelJob

func (e *GrpcEndpoint) ModuleCancelJob(_ context.Context, in *pb.ModuleJobRequest) (*pb.JobResponse, error)

ModuleCancelJob <- ModuleJobRequest -> JobResponse

func (*GrpcEndpoint) ModuleSubmitEvent

func (e *GrpcEndpoint) ModuleSubmitEvent(_ context.Context, in *pb.ModuleEventRequest) (*pb.JobResponse, error)

ModuleSubmitEvent <- ModuleEventRequest -> JobResponse

func (*GrpcEndpoint) ModuleSubmitJob

func (e *GrpcEndpoint) ModuleSubmitJob(_ context.Context, in *pb.ModuleJobRequest) (*pb.JobResponse, error)

ModuleSubmitJob <- ModuleJobRequest -> JobResponse

func (*GrpcEndpoint) SetModuleProperties

func (e *GrpcEndpoint) SetModuleProperties(_ context.Context, in *pb.PropertiesRequest) (*pb.PropertiesResponse, error)

SetModuleProperties <- PropertiesRequest -> PropertiesResponse

func (*GrpcEndpoint) SetModuleProperty

func (e *GrpcEndpoint) SetModuleProperty(_ context.Context, in *pb.PropertyRequest) (*pb.PropertyResponse, error)

SetModuleProperty <- PropertyRequest -> PropertyResponse

func (*GrpcEndpoint) TryModuleConnect

func (e *GrpcEndpoint) TryModuleConnect(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleConnect <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleDisable

func (e *GrpcEndpoint) TryModuleDisable(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleDisable <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleDisconnect

func (e *GrpcEndpoint) TryModuleDisconnect(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleDisconnect <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleEnable

func (e *GrpcEndpoint) TryModuleEnable(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleEnable <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleLoad

func (e *GrpcEndpoint) TryModuleLoad(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleLoad <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleReload

func (e *GrpcEndpoint) TryModuleReload(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleReload <- ModuleRequest -> JobResponse

func (*GrpcEndpoint) TryModuleUnload

func (e *GrpcEndpoint) TryModuleUnload(_ context.Context, in *pb.ModuleRequest) (*pb.JobResponse, error)

TryModuleUnload <- ModuleRequest -> JobResponse

type GrpcService

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

GrpcService defines an instance of the request relay service.

func NewGrpcService

func NewGrpcService(name string, config *gcontext.Config) (service *GrpcService, err error)

NewGrpcService creates an instance of the service class.

func (*GrpcService) Start

func (s *GrpcService) Start(ctx context.Context, wg *sync.WaitGroup) error

Start launches the service.

type MdpEndpoint

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

MdpEndpoint defines a service that handles ZeroMQ MDP messages.

func NewMdpEndpoint

func NewMdpEndpoint(name string, endpoint string) *MdpEndpoint

NewMdpEndpoint creates an instance of the endpoint class.

func (*MdpEndpoint) HandleRequest

func (e *MdpEndpoint) HandleRequest(ctx context.Context, request []string) ([]string, error)

func (*MdpEndpoint) Start

func (e *MdpEndpoint) Start(ctx context.Context)

type MdpService

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

MdpService defines an instance of the MDP request handling service.

This service isn't a fully-formed idea yet, the existing gRPC service is meant to proxy calls to MDP but we don't need to do that to go from MDP to MDP. It would make the most sense here to create a service class with a worker pool where the workers connect to this broker and are handling broker specific requests over MDP. This should probably be removed until it's actually needed, but it doesn't do anything and is never created so for now it's being left in.

func NewMdpService

func NewMdpService(name string, config *gcontext.Config) (*MdpService, error)

NewMdpService creates an instance of the service class.

func (*MdpService) Start

func (s *MdpService) Start(ctx context.Context, wg *sync.WaitGroup) error

Start launches the service.

type ResponseError

type ResponseError struct {
	Code    int32
	Message string
}

ResponseError is used to assign error codes to responses

func MultipleRepliesError

func MultipleRepliesError() ResponseError

MultipleRepliesError creates an instance of the error class for a request response that received multiple replies.

func UnexpectedResponseError

func UnexpectedResponseError() ResponseError

UnexpectedResponseError creates an instance of the error class for an unexpected response.

func UnmarshalFailedError

func UnmarshalFailedError() ResponseError

UnmarshalFailedError creates an instance of the error class to use when the unmarshalling process has failed.

func (ResponseError) Error

func (e ResponseError) Error() string

Error writes the code and message into a string

type Service

type Service interface {
	Start(ctx context.Context, wg *sync.WaitGroup) error
}

Service defines an interface for message handling services.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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