agent

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Agent

Agent service provides a barebones HTTP and gRPC API and Service interface implementation for the development of the agent service.

Configuration

The service is configured using the environment variables from the following table. Note that any unset variables will be replaced with their default values.

Variable Description Default
AGENT_LOG_LEVEL Log level for agent service (debug, info, warn, error) info
AGENT_HTTP_HOST Agent service HTTP host ""
AGENT_HTTP_PORT Agent service HTTP port 9031
AGENT_HTTP_SERVER_CERT Path to HTTP server certificate in pem format ""
AGENT_HTTP_SERVER_KEY Path to HTTP server key in pem format ""
AGENT_GRPC_HOST Agent service gRPC host ""
AGENT_GRPC_PORT Agent service gRPC port 7002
AGENT_GRPC_SERVER_CERT Path to gRPC server certificate in pem format ""
AGENT_GRPC_SERVER_KEY Path to gRPC server key in pem format ""
COCOS_NOTIFICATION_SERVER_URL Server to receive notification events from agent. http:/localhost:9000

Deployment

To start the service outside of the container, execute the following shell script:

# download the latest version of the service
go get github.com/ultravioletrs/cocos

cd $GOPATH/src/github.com/ultravioletrs/cocos

# compile the agent
make agent

# set the environment variables and run the service
./build/cocos-agent

Usage

For more information about service capabilities and its usage, please check out the README documentation.

Documentation

Overview

Copyright (c) Ultraviolet SPDX-License-Identifier: Apache-2.0

Copyright (c) Ultraviolet SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	AgentService_Algo_FullMethodName        = "/agent.AgentService/Algo"
	AgentService_Data_FullMethodName        = "/agent.AgentService/Data"
	AgentService_Result_FullMethodName      = "/agent.AgentService/Result"
	AgentService_Attestation_FullMethodName = "/agent.AgentService/Attestation"
)

Variables

View Source
var (
	// ErrMalformedEntity indicates malformed entity specification (e.g.
	// invalid username or password).
	ErrMalformedEntity = errors.New("malformed entity specification")
	// ErrUnauthorizedAccess indicates missing or invalid credentials provided
	// when accessing a protected resource.
	ErrUnauthorizedAccess = errors.New("missing or invalid credentials provided")
)
View Source
var AgentService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "agent.AgentService",
	HandlerType: (*AgentServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Algo",
			Handler:    _AgentService_Algo_Handler,
		},
		{
			MethodName: "Data",
			Handler:    _AgentService_Data_Handler,
		},
		{
			MethodName: "Result",
			Handler:    _AgentService_Result_Handler,
		},
		{
			MethodName: "Attestation",
			Handler:    _AgentService_Attestation_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "agent/agent.proto",
}

AgentService_ServiceDesc is the grpc.ServiceDesc for AgentService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_agent_agent_proto protoreflect.FileDescriptor

Functions

func RegisterAgentServiceServer

func RegisterAgentServiceServer(s grpc.ServiceRegistrar, srv AgentServiceServer)

Types

type AgentServiceClient

type AgentServiceClient interface {
	Algo(ctx context.Context, in *AlgoRequest, opts ...grpc.CallOption) (*AlgoResponse, error)
	Data(ctx context.Context, in *DataRequest, opts ...grpc.CallOption) (*DataResponse, error)
	Result(ctx context.Context, in *ResultRequest, opts ...grpc.CallOption) (*ResultResponse, error)
	Attestation(ctx context.Context, in *AttestationRequest, opts ...grpc.CallOption) (*AttestationResponse, error)
}

AgentServiceClient is the client API for AgentService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type AgentServiceServer

type AgentServiceServer interface {
	Algo(context.Context, *AlgoRequest) (*AlgoResponse, error)
	Data(context.Context, *DataRequest) (*DataResponse, error)
	Result(context.Context, *ResultRequest) (*ResultResponse, error)
	Attestation(context.Context, *AttestationRequest) (*AttestationResponse, error)
	// contains filtered or unexported methods
}

AgentServiceServer is the server API for AgentService service. All implementations must embed UnimplementedAgentServiceServer for forward compatibility

type AlgoRequest

type AlgoRequest struct {
	Algorithm []byte `protobuf:"bytes,1,opt,name=algorithm,proto3" json:"algorithm,omitempty"`
	Provider  string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"`
	Id        string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*AlgoRequest) Descriptor deprecated

func (*AlgoRequest) Descriptor() ([]byte, []int)

Deprecated: Use AlgoRequest.ProtoReflect.Descriptor instead.

func (*AlgoRequest) GetAlgorithm

func (x *AlgoRequest) GetAlgorithm() []byte

func (*AlgoRequest) GetId

func (x *AlgoRequest) GetId() string

func (*AlgoRequest) GetProvider

func (x *AlgoRequest) GetProvider() string

func (*AlgoRequest) ProtoMessage

func (*AlgoRequest) ProtoMessage()

func (*AlgoRequest) ProtoReflect

func (x *AlgoRequest) ProtoReflect() protoreflect.Message

func (*AlgoRequest) Reset

func (x *AlgoRequest) Reset()

func (*AlgoRequest) String

func (x *AlgoRequest) String() string

type AlgoResponse

type AlgoResponse struct {
	AlgorithmID string `protobuf:"bytes,1,opt,name=algorithmID,proto3" json:"algorithmID,omitempty"`
	// contains filtered or unexported fields
}

func (*AlgoResponse) Descriptor deprecated

func (*AlgoResponse) Descriptor() ([]byte, []int)

Deprecated: Use AlgoResponse.ProtoReflect.Descriptor instead.

func (*AlgoResponse) GetAlgorithmID

func (x *AlgoResponse) GetAlgorithmID() string

func (*AlgoResponse) ProtoMessage

func (*AlgoResponse) ProtoMessage()

func (*AlgoResponse) ProtoReflect

func (x *AlgoResponse) ProtoReflect() protoreflect.Message

func (*AlgoResponse) Reset

func (x *AlgoResponse) Reset()

func (*AlgoResponse) String

func (x *AlgoResponse) String() string

type Algorithm

type Algorithm struct {
	Algorithm []byte `json:"-"`
	Provider  string `json:"provider,omitempty"`
	ID        string `json:"id,omitempty"`
}

type AlgorithmReq

type AlgorithmReq struct {
	Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"`
	Id       string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*AlgorithmReq) Descriptor deprecated

func (*AlgorithmReq) Descriptor() ([]byte, []int)

Deprecated: Use AlgorithmReq.ProtoReflect.Descriptor instead.

func (*AlgorithmReq) GetId

func (x *AlgorithmReq) GetId() string

func (*AlgorithmReq) GetProvider

func (x *AlgorithmReq) GetProvider() string

func (*AlgorithmReq) ProtoMessage

func (*AlgorithmReq) ProtoMessage()

func (*AlgorithmReq) ProtoReflect

func (x *AlgorithmReq) ProtoReflect() protoreflect.Message

func (*AlgorithmReq) Reset

func (x *AlgorithmReq) Reset()

func (*AlgorithmReq) String

func (x *AlgorithmReq) String() string

type Algorithms

type Algorithms []Algorithm

func (*Algorithms) String

func (a *Algorithms) String() string

type AttestationRequest

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

func (*AttestationRequest) Descriptor deprecated

func (*AttestationRequest) Descriptor() ([]byte, []int)

Deprecated: Use AttestationRequest.ProtoReflect.Descriptor instead.

func (*AttestationRequest) ProtoMessage

func (*AttestationRequest) ProtoMessage()

func (*AttestationRequest) ProtoReflect

func (x *AttestationRequest) ProtoReflect() protoreflect.Message

func (*AttestationRequest) Reset

func (x *AttestationRequest) Reset()

func (*AttestationRequest) String

func (x *AttestationRequest) String() string

type AttestationResponse

type AttestationResponse struct {
	File []byte `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"`
	// contains filtered or unexported fields
}

func (*AttestationResponse) Descriptor deprecated

func (*AttestationResponse) Descriptor() ([]byte, []int)

Deprecated: Use AttestationResponse.ProtoReflect.Descriptor instead.

func (*AttestationResponse) GetFile

func (x *AttestationResponse) GetFile() []byte

func (*AttestationResponse) ProtoMessage

func (*AttestationResponse) ProtoMessage()

func (*AttestationResponse) ProtoReflect

func (x *AttestationResponse) ProtoReflect() protoreflect.Message

func (*AttestationResponse) Reset

func (x *AttestationResponse) Reset()

func (*AttestationResponse) String

func (x *AttestationResponse) String() string

type Computation

type Computation struct {
	ID              string     `json:"id,omitempty"`
	Name            string     `json:"name,omitempty"`
	Description     string     `json:"description,omitempty"`
	Datasets        Datasets   `json:"datasets,omitempty"`
	Algorithms      Algorithms `json:"algorithms,omitempty"`
	ResultConsumers []string   `json:"result_consumers,omitempty"`
}

type ComputationReq

type ComputationReq struct {
	Id              string          `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Name            string          `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Description     string          `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	Datasets        []*DatasetReq   `protobuf:"bytes,4,rep,name=datasets,proto3" json:"datasets,omitempty"`
	Algorithms      []*AlgorithmReq `protobuf:"bytes,5,rep,name=algorithms,proto3" json:"algorithms,omitempty"`
	ResultConsumers []string        `protobuf:"bytes,6,rep,name=result_consumers,json=resultConsumers,proto3" json:"result_consumers,omitempty"`
	// contains filtered or unexported fields
}

func (*ComputationReq) Descriptor deprecated

func (*ComputationReq) Descriptor() ([]byte, []int)

Deprecated: Use ComputationReq.ProtoReflect.Descriptor instead.

func (*ComputationReq) GetAlgorithms

func (x *ComputationReq) GetAlgorithms() []*AlgorithmReq

func (*ComputationReq) GetDatasets

func (x *ComputationReq) GetDatasets() []*DatasetReq

func (*ComputationReq) GetDescription

func (x *ComputationReq) GetDescription() string

func (*ComputationReq) GetId

func (x *ComputationReq) GetId() string

func (*ComputationReq) GetName

func (x *ComputationReq) GetName() string

func (*ComputationReq) GetResultConsumers

func (x *ComputationReq) GetResultConsumers() []string

func (*ComputationReq) ProtoMessage

func (*ComputationReq) ProtoMessage()

func (*ComputationReq) ProtoReflect

func (x *ComputationReq) ProtoReflect() protoreflect.Message

func (*ComputationReq) Reset

func (x *ComputationReq) Reset()

func (*ComputationReq) String

func (x *ComputationReq) String() string

type DataRequest

type DataRequest struct {
	Dataset  []byte `protobuf:"bytes,1,opt,name=dataset,proto3" json:"dataset,omitempty"`
	Provider string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"`
	Id       string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*DataRequest) Descriptor deprecated

func (*DataRequest) Descriptor() ([]byte, []int)

Deprecated: Use DataRequest.ProtoReflect.Descriptor instead.

func (*DataRequest) GetDataset

func (x *DataRequest) GetDataset() []byte

func (*DataRequest) GetId

func (x *DataRequest) GetId() string

func (*DataRequest) GetProvider

func (x *DataRequest) GetProvider() string

func (*DataRequest) ProtoMessage

func (*DataRequest) ProtoMessage()

func (*DataRequest) ProtoReflect

func (x *DataRequest) ProtoReflect() protoreflect.Message

func (*DataRequest) Reset

func (x *DataRequest) Reset()

func (*DataRequest) String

func (x *DataRequest) String() string

type DataResponse

type DataResponse struct {
	DatasetID string `protobuf:"bytes,1,opt,name=datasetID,proto3" json:"datasetID,omitempty"`
	// contains filtered or unexported fields
}

func (*DataResponse) Descriptor deprecated

func (*DataResponse) Descriptor() ([]byte, []int)

Deprecated: Use DataResponse.ProtoReflect.Descriptor instead.

func (*DataResponse) GetDatasetID

func (x *DataResponse) GetDatasetID() string

func (*DataResponse) ProtoMessage

func (*DataResponse) ProtoMessage()

func (*DataResponse) ProtoReflect

func (x *DataResponse) ProtoReflect() protoreflect.Message

func (*DataResponse) Reset

func (x *DataResponse) Reset()

func (*DataResponse) String

func (x *DataResponse) String() string

type Dataset

type Dataset struct {
	Dataset  []byte `json:"-"`
	Provider string `json:"provider,omitempty"`
	ID       string `json:"id,omitempty"`
}

type DatasetReq

type DatasetReq struct {
	Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"`
	Id       string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetReq) Descriptor deprecated

func (*DatasetReq) Descriptor() ([]byte, []int)

Deprecated: Use DatasetReq.ProtoReflect.Descriptor instead.

func (*DatasetReq) GetId

func (x *DatasetReq) GetId() string

func (*DatasetReq) GetProvider

func (x *DatasetReq) GetProvider() string

func (*DatasetReq) ProtoMessage

func (*DatasetReq) ProtoMessage()

func (*DatasetReq) ProtoReflect

func (x *DatasetReq) ProtoReflect() protoreflect.Message

func (*DatasetReq) Reset

func (x *DatasetReq) Reset()

func (*DatasetReq) String

func (x *DatasetReq) String() string

type Datasets

type Datasets []Dataset

func (*Datasets) String

func (d *Datasets) String() string

type ResultRequest

type ResultRequest struct {
	Consumer string `protobuf:"bytes,1,opt,name=consumer,proto3" json:"consumer,omitempty"`
	// contains filtered or unexported fields
}

func (*ResultRequest) Descriptor deprecated

func (*ResultRequest) Descriptor() ([]byte, []int)

Deprecated: Use ResultRequest.ProtoReflect.Descriptor instead.

func (*ResultRequest) GetConsumer

func (x *ResultRequest) GetConsumer() string

func (*ResultRequest) ProtoMessage

func (*ResultRequest) ProtoMessage()

func (*ResultRequest) ProtoReflect

func (x *ResultRequest) ProtoReflect() protoreflect.Message

func (*ResultRequest) Reset

func (x *ResultRequest) Reset()

func (*ResultRequest) String

func (x *ResultRequest) String() string

type ResultResponse

type ResultResponse struct {
	File []byte `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"`
	// contains filtered or unexported fields
}

func (*ResultResponse) Descriptor deprecated

func (*ResultResponse) Descriptor() ([]byte, []int)

Deprecated: Use ResultResponse.ProtoReflect.Descriptor instead.

func (*ResultResponse) GetFile

func (x *ResultResponse) GetFile() []byte

func (*ResultResponse) ProtoMessage

func (*ResultResponse) ProtoMessage()

func (*ResultResponse) ProtoReflect

func (x *ResultResponse) ProtoReflect() protoreflect.Message

func (*ResultResponse) Reset

func (x *ResultResponse) Reset()

func (*ResultResponse) String

func (x *ResultResponse) String() string

type Service

type Service interface {
	Run(ctx context.Context, c Computation) (string, error)
	Algo(ctx context.Context, algorithm Algorithm) (string, error)
	Data(ctx context.Context, dataset Dataset) (string, error)
	Result(ctx context.Context, consumer string) ([]byte, error)
	Attestation(ctx context.Context) ([]byte, error)
}

Service specifies an API that must be fullfiled by the domain service implementation, and all of its decorators (e.g. logging & metrics).

func New

func New(ctx context.Context, logger mglog.Logger, eventSvc events.Service) Service

New instantiates the agent service implementation.

type StateMachine

type StateMachine struct {
	State          state
	EventChan      chan event
	Transitions    map[state]map[event]state
	StateFunctions map[state]func()
	// contains filtered or unexported fields
}

StateMachine represents the state machine.

func NewStateMachine

func NewStateMachine(logger mglog.Logger) *StateMachine

NewStateMachine creates a new StateMachine.

func (*StateMachine) GetState

func (sm *StateMachine) GetState() state

func (*StateMachine) SendEvent

func (sm *StateMachine) SendEvent(event event)

SendEvent sends an event to the state machine.

func (*StateMachine) SetState

func (sm *StateMachine) SetState(state state)

func (*StateMachine) Start

func (sm *StateMachine) Start(ctx context.Context)

Start the state machine.

type UnimplementedAgentServiceServer

type UnimplementedAgentServiceServer struct {
}

UnimplementedAgentServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedAgentServiceServer) Algo

func (UnimplementedAgentServiceServer) Attestation

func (UnimplementedAgentServiceServer) Data

func (UnimplementedAgentServiceServer) Result

type UnsafeAgentServiceServer

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

UnsafeAgentServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to AgentServiceServer will result in compilation errors.

Directories

Path Synopsis
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.

Jump to

Keyboard shortcuts

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