services

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 28 Imported by: 6

Documentation

Index

Constants

Variables

This section is empty.

Functions

func AgentLogger added in v0.0.26

func AgentLogger(ctx context.Context) *agents.AgentLogger

func ConfigureError added in v0.0.26

func ConfigureError(err error) *runtimev1.ConfigureStatus

func ConfigureSuccess added in v0.0.26

func ConfigureSuccess() *runtimev1.ConfigureStatus

func NetworkMappingForRoute added in v0.0.28

func NetworkMappingForRoute(ctx context.Context, route *configurations.RestRoute, mappings []*runtimev1.NetworkMapping) (*runtimev1.NetworkMapping, error)

NetworkMappingForRoute finds the proper network mapping for a given route

func NewFactoryAgent added in v0.0.26

func NewFactoryAgent(conf *configurations.Agent, factory IFactory) agents.AgentImplementation

func NewRuntimeAgent added in v0.0.26

func NewRuntimeAgent(conf *configurations.Agent, runtime IRuntime) agents.AgentImplementation

func ServiceLogger added in v0.0.26

func ServiceLogger(ctx context.Context) *agents.ServiceLogger

func StartError added in v0.0.26

func StartError(err error) *runtimev1.StartStatus

func StartSuccess added in v0.0.26

func StartSuccess() *runtimev1.StartStatus

func WithDestination added in v0.0.31

func WithDestination(destination string, args ...any) templates.TemplateOptionFunc

Types

type Base added in v0.0.26

type Base struct {
	// Agent
	Agent *configurations.Agent

	// State
	Identity *servicev1.ServiceIdentity
	Location string

	// codefly configuration
	ConfigurationLocation string

	Configuration *configurations.Service

	// Information convenience
	Information *Information

	// Endpoints
	Endpoints []*basev1.Endpoint

	// Runtime
	State InformationStatus

	// Loggers
	ServiceLogger *agents.ServiceLogger
	AgentLogger   *agents.AgentLogger

	// Communication Manager
	CommunicationClientManager *communicate.ClientManager

	// Code Watcher
	Watcher *code.Watcher
	Events  chan code.Change
	// contains filtered or unexported fields
}

func NewServiceBase added in v0.0.26

func NewServiceBase(agent *configurations.Agent) *Base

func (*Base) Communicate added in v0.0.26

func (s *Base) Communicate(eng *agentsv1.Engage) (*agentsv1.InformationRequest, error)

func (*Base) Context added in v0.0.26

func (s *Base) Context() context.Context

func (*Base) Create added in v0.0.26

func (s *Base) Create(settings any, endpoints ...*basev1.Endpoint) (*factoryv1.CreateResponse, error)

func (*Base) DebugMe added in v0.0.26

func (s *Base) DebugMe(format string, args ...any)

func (*Base) DockerImage added in v0.0.31

func (s *Base) DockerImage() *configurations.DockerImage

func (*Base) EndpointsFromConfiguration added in v0.0.26

func (s *Base) EndpointsFromConfiguration() ([]*basev1.Endpoint, error)

EndpointsFromConfiguration from Configuration and data from the service

func (*Base) Errorf added in v0.0.28

func (s *Base) Errorf(format string, args ...interface{}) error

func (*Base) FactoryInitResponse added in v0.0.31

func (s *Base) FactoryInitResponse(es []*basev1.Endpoint, channels []*agentsv1.Channel, readme string) (*factoryv1.InitResponse, error)

func (*Base) FactoryInitResponseError added in v0.0.26

func (s *Base) FactoryInitResponseError(err error) (*factoryv1.InitResponse, error)

func (*Base) Init added in v0.0.26

func (s *Base) Init(req *servicev1.InitRequest, settings any) error

func (*Base) Local added in v0.0.26

func (s *Base) Local(f string) string

func (*Base) RuntimeInitResponse added in v0.0.26

func (s *Base) RuntimeInitResponse(endpoints []*basev1.Endpoint, channels ...*agentsv1.Channel) (*runtimev1.InitResponse, error)

func (*Base) RuntimeInitResponseError added in v0.0.26

func (s *Base) RuntimeInitResponseError(err error) (*runtimev1.InitResponse, error)

func (*Base) SetupWatcher added in v0.0.26

func (s *Base) SetupWatcher(conf *WatchConfiguration, handler func(event code.Change) error) error

func (*Base) Stop added in v0.0.26

func (s *Base) Stop() error

func (*Base) Templates added in v0.0.26

func (s *Base) Templates(obj any, ws ...TemplateWrapper) error

func (*Base) Version added in v0.0.26

func (s *Base) Version() *servicev1.Version

func (*Base) WantRestart added in v0.0.26

func (s *Base) WantRestart()

func (*Base) WantSync added in v0.0.26

func (s *Base) WantSync()

func (*Base) Wire added in v0.0.26

func (s *Base) Wire(method agentsv1.Method, client *communicate.ClientContext) error

func (*Base) WithCommunications added in v0.0.26

func (s *Base) WithCommunications(channels ...*Channel) ([]*agentsv1.Channel, error)

func (*Base) Wrapf added in v0.0.26

func (s *Base) Wrapf(err error, format string, args ...interface{}) error

type Channel added in v0.0.26

type Channel struct {
	Method agentsv1.Method
	Client *communicate.ClientContext
}

func NewChannel added in v0.0.26

func NewChannel(method agentsv1.Method, client *communicate.ClientContext) *Channel

func NewDynamicChannel added in v0.0.26

func NewDynamicChannel(method agentsv1.Method) *Channel

type FactoryServer added in v0.0.26

type FactoryServer struct {
	factoryv1.UnimplementedFactoryServer
	Factory IFactory
}

FactoryServer wraps the gRPC protocol Request/Response

func (*FactoryServer) Build added in v0.0.26

func (*FactoryServer) Communicate added in v0.0.26

func (*FactoryServer) Create added in v0.0.26

func (*FactoryServer) Deploy added in v0.0.26

func (*FactoryServer) Init added in v0.0.26

func (*FactoryServer) Sync added in v0.0.26

func (*FactoryServer) Update added in v0.0.26

type Information added in v0.0.26

type Information struct {
	Service *configurations.ServiceWithCase
	Agent   *configurations.Agent
	Domain  string
}

type InformationStatus added in v0.0.26

type InformationStatus = runtimev1.InformationResponse_Status

type ProcessState

type ProcessState int
const (
	Unknown  ProcessState = iota
	NotFound ProcessState = iota
	Running
	InterruptibleSleep
	UninterruptibleSleep
	Stopped
	Zombie
	Dead
	TracingStop
	Idle
	Parked
	Waking
)

func (ProcessState) String

func (ps ProcessState) String() string

type RuntimeServer added in v0.0.26

type RuntimeServer struct {
	runtimev1.UnimplementedRuntimeServer
	Runtime IRuntime
}

RuntimeServer wraps the gRPC protocol Request/Response

func (*RuntimeServer) Communicate added in v0.0.26

func (*RuntimeServer) Configure added in v0.0.26

func (*RuntimeServer) Information added in v0.0.26

func (*RuntimeServer) Init added in v0.0.26

func (*RuntimeServer) Start added in v0.0.26

func (*RuntimeServer) Stop added in v0.0.26

type ServiceEvent

type ServiceEvent struct {
	Unique string
	Event  string
}

type ServiceFactory added in v0.0.26

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

func LoadFactory added in v0.0.26

func LoadFactory(conf *configurations.Service) (*ServiceFactory, error)

func (ServiceFactory) Build added in v0.0.26

func (ServiceFactory) Communicate added in v0.0.26

func (ServiceFactory) Create added in v0.0.26

func (ServiceFactory) Deploy added in v0.0.26

func (ServiceFactory) Init added in v0.0.26

func (ServiceFactory) Sync added in v0.0.26

func (ServiceFactory) Update added in v0.0.26

type ServiceFactoryAgent added in v0.0.26

type ServiceFactoryAgent struct {
	// GRPCAgent must still implement the Agent interface
	plugin.Plugin
	Factory IFactory
}

func (*ServiceFactoryAgent) GRPCClient added in v0.0.26

func (p *ServiceFactoryAgent) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ServiceFactoryAgent) GRPCServer added in v0.0.26

func (p *ServiceFactoryAgent) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type ServiceFactoryAgentContext added in v0.0.26

type ServiceFactoryAgentContext struct {
}

func (ServiceFactoryAgentContext) Default added in v0.0.26

func (m ServiceFactoryAgentContext) Default() plugin.Plugin

func (ServiceFactoryAgentContext) Key added in v0.0.26

type ServiceRuntime added in v0.0.26

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

func LoadRuntime added in v0.0.26

func LoadRuntime(service *configurations.Service, opts ...agents.Option) (*ServiceRuntime, error)

func (*ServiceRuntime) Communicate added in v0.0.26

Communicate helper

func (*ServiceRuntime) Configure added in v0.0.26

Configure documents things It can be used safely anywhere: doesn't start or do anything

func (*ServiceRuntime) Information added in v0.0.26

Information return some useful information about the service

func (*ServiceRuntime) Init added in v0.0.26

Init initializes the service

func (*ServiceRuntime) Start added in v0.0.26

Start starts the service

func (*ServiceRuntime) Stop added in v0.0.26

Stop stops the service

type ServiceRuntimeAgent added in v0.0.26

type ServiceRuntimeAgent struct {
	// GRPCAgent must still implement the Agent interface
	plugin.Plugin
	Runtime IRuntime
}

func (*ServiceRuntimeAgent) GRPCClient added in v0.0.26

func (p *ServiceRuntimeAgent) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ServiceRuntimeAgent) GRPCServer added in v0.0.26

func (p *ServiceRuntimeAgent) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type ServiceRuntimeAgentContext added in v0.0.26

type ServiceRuntimeAgentContext struct {
}

func (ServiceRuntimeAgentContext) Default added in v0.0.26

func (m ServiceRuntimeAgentContext) Default() plugin.Plugin

func (ServiceRuntimeAgentContext) Key added in v0.0.26

type ServiceRuntimeLoader added in v0.0.26

type ServiceRuntimeLoader struct {
	Logger hclog.Logger
}

type SingleTracker

type SingleTracker struct {
	Tracked Tracked

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*SingleTracker) Stop

func (t *SingleTracker) Stop()

type TemplateWrapper added in v0.0.26

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

func WithBuilder added in v0.0.26

func WithBuilder(fs embed.FS) TemplateWrapper

func WithDeployment added in v0.0.26

func WithDeployment(fs embed.FS) TemplateWrapper

func WithDeploymentFor added in v0.0.26

func WithDeploymentFor(fs embed.FS, relativePath string, opts ...templates.TemplateOptionFunc) TemplateWrapper

func WithFactory added in v0.0.26

func WithFactory(fs embed.FS, ignores ...string) TemplateWrapper

type Tracked

type Tracked interface {
	Name() string   // For display
	Unique() string // For identification in the system
	GetStatus() (ProcessState, error)
	GetUsage() (*Usage, error)
	Kill() error
}

func NewTracked

func NewTracked(service *configurations.Service, tracker *runtimev1.Tracker) (Tracked, error)

type TrackedContainer

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

func (TrackedContainer) GetStatus

func (t TrackedContainer) GetStatus() (ProcessState, error)

func (TrackedContainer) GetUsage

func (t TrackedContainer) GetUsage() (*Usage, error)

func (TrackedContainer) Kill

func (t TrackedContainer) Kill() error

func (TrackedContainer) Name

func (t TrackedContainer) Name() string

func (TrackedContainer) Unique

func (t TrackedContainer) Unique() string

type TrackedProcess

type TrackedProcess struct {
	PID    int
	Killed bool
	// contains filtered or unexported fields
}

func (*TrackedProcess) GetStatus

func (p *TrackedProcess) GetStatus() (ProcessState, error)

func (*TrackedProcess) GetUsage

func (p *TrackedProcess) GetUsage() (*Usage, error)

func (*TrackedProcess) Kill

func (p *TrackedProcess) Kill() error

func (*TrackedProcess) Name

func (p *TrackedProcess) Name() string

func (*TrackedProcess) Proto

func (p *TrackedProcess) Proto() *runtimev1.Tracker

func (*TrackedProcess) Unique

func (p *TrackedProcess) Unique() string

type Tracker

type Tracker interface {
	Start(events chan<- ServiceEvent) error
	Stop()
}

type Usage

type Usage struct {
	Memory float64 // In KB
	CPU    float64
}

type WatchConfiguration added in v0.0.26

type WatchConfiguration struct {
	Includes []string
	Excludes []string
}

func NewWatchConfiguration added in v0.0.26

func NewWatchConfiguration(includes []string, excludes ...string) *WatchConfiguration

Jump to

Keyboard shortcuts

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