common

package
v0.0.0-...-b9c5443 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package common regroup structures used by the orchestrator.

Index

Constants

This section is empty.

Variables

View Source
var ReadOnlyMethods = map[string][]string{
	"Metric":        {"GetMetric", "QueryMetrics"},
	"Organization":  {"GetAllOrganizations"},
	"Function":      {"GetFunction", "QueryFunctions"},
	"Event":         {"QueryEvents"},
	"Model":         {"GetComputeTaskOutputModels", "CanDisableModel", "GetModel"},
	"Dataset":       {"GetDataset"},
	"DataSample":    {"GetDataSample", "QueryDataSamples"},
	"DataManager":   {"GetDataManager", "QueryDataManagers"},
	"ComputeTask":   {"QueryTasks", "GetTask", "GetTaskInputAssets"},
	"ComputePlan":   {"GetPlan", "QueryPlans", "IsPlanRunning"},
	"Performance":   {"QueryPerformances"},
	"Info":          {"QueryVersion"},
	"FailureReport": {"GetFailureReport"},
}

ReadOnlyMethods maps for service "read only" methods. This mapping is used to set transactions as "read only"

View Source
var Version = "dev"

Version represents the version of the server, the value is changed at build time

Functions

func GetEnv

func GetEnv(name string) (string, bool)

GetEnv attempts to get an environment variable Every env var is prefixed by ORCHESTRATOR_

func GetEnvOrFallback

func GetEnvOrFallback(name string, fallback string) string

GetEnvOrFallback attempts to get an environment variable or fallback to the provided default value. Every env var is prefixed by ORCHESTRATOR_.

func GetKeepAliveOptions

func GetKeepAliveOptions() grpc.ServerOption

GetKeepAliveOptions will return server option with gRPC keepalive setup. This may panic on missing or invalid configuration env var.

func GetTLSOptions

func GetTLSOptions() grpc.ServerOption

GetTLSOptions will return server option with optional TLS and mTLS setup. This may panic on missing or invalid configuration env var.

func MustGetEnv

func MustGetEnv(name string) string

MustGetEnv extract environment variable or abort with an error message Every env var is prefixed with ORCHESTRATOR_

func MustGetEnvFlag

func MustGetEnvFlag(name string) bool

MustGetEnvFlag extracts and environment variable and returns a boolean corresponding to its value ("true" is true, anything else is false). If the environment variable is not found, the program panics with an error message. Every env var is prefixed with "ORCHESTRATOR_".

func MustParseBool

func MustParseBool(s string) bool

MustParseBool parse input as bool or log and exit

func MustParseDuration

func MustParseDuration(duration string) time.Duration

MustParseDuration parse input as a duration or log and exit.

func MustParseInt

func MustParseInt(s string) int

MustParseInt parse input as int or log and exit.

Types

type AppParameters

type AppParameters struct {
	GrpcOptions []grpc.ServerOption
	Config      *OrchestratorConfiguration
	RetryBudget time.Duration
}

AppParameters are settings used by the application.

type ContextualizedServerStream

type ContextualizedServerStream struct {
	grpc.ServerStream
	// contains filtered or unexported fields
}

func BindStreamToContext

func BindStreamToContext(ctx context.Context, stream grpc.ServerStream) *ContextualizedServerStream

func (*ContextualizedServerStream) Context

type GrpcMethodChecker

type GrpcMethodChecker struct{}

func (GrpcMethodChecker) IsEvaluateMethod

func (c GrpcMethodChecker) IsEvaluateMethod(method string) bool

IsEvaluateMethod maps for each gRPC service its "read only" methods. Those are methods which should not have any side effect on the storage, ie: they should not write to the database or ledger. It is used to initiate read-only transactions when possible.

type MemoryQueue

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

MemoryQueue keeps events in memory

func (*MemoryQueue) Enqueue

func (q *MemoryQueue) Enqueue(event *asset.Event) error

Enqueue adds an event to the queue

func (*MemoryQueue) GetEvents

func (q *MemoryQueue) GetEvents() []*asset.Event

GetEvents returns queued events

func (*MemoryQueue) Len

func (q *MemoryQueue) Len() int

Len returns the length of the queue

type OrchestratorConfiguration

type OrchestratorConfiguration struct {
	// map of channels -> organizations
	Channels map[string][]string `yaml:"channels"`
}

OrchestratorConfiguration describe the business config of the server. Contrary to the technical conf item which are received as env var, some business details are passed as a yml config file.

func NewConfig

func NewConfig(path string) *OrchestratorConfiguration

type OrgCACertList

type OrgCACertList = map[string][]string

func GetOrgCACerts

func GetOrgCACerts() (OrgCACertList, error)

GetOrgCACerts returns the valid CA keys per organization (mspid).

type Runnable

type Runnable interface {
	GetGrpcServer() *grpc.Server
	Stop()
}

Runnable is the opaque interface behind which servers are handled

type TransactionChecker

type TransactionChecker interface {
	// IsEvaluateMethod returns true if the gRPC method has no side effect (read-only).
	IsEvaluateMethod(method string) bool
}

TransactionChecker is able to characterize a transaction based on the gRPC method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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