server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigK8s

func ConfigK8s(ctx context.Context, namespace string, name string) (values map[string]string, err kv.Error)

ConfigK8s is used to pull the values from a named config map in k8s

This function will return an empty map and and error value on failure.

func GetPrometheusPort

func GetPrometheusPort() (port int)

Allows testing software to query which port is being used by the prometheus metrics server resident inside the current server process

func InitiateK8s

func InitiateK8s(ctx context.Context, namespace string, cfgMap string, readyC chan struct{}, staleMsg time.Duration, logger *log.Logger, errorC chan kv.Error)

initiateK8s runs until either ctx is Done or the listener is running successfully

func IsAliveK8s

func IsAliveK8s() (err kv.Error)

IsAliveK8s is used to extract any kv.in the state of the k8s client api connection.

A nil returned indicates k8s is working and in use, otherwise a descriptive error is returned.

func K8sUpdateSecret

func K8sUpdateSecret(config string, secret string, content []byte) (err kv.Error)

func ListenK8s

func ListenK8s(ctx context.Context, namespace string, globalMap string, podMap string, updateC chan<- K8sStateUpdate, errC chan<- kv.Error) (err kv.Error)

ListenK8s will register a listener to watch for pod specific configMaps in k8s and will relay state changes to a channel, the global state map should exist at the bare minimum. A state change in either map superseded any previous state.

This is a blocking function that will return either upon an error in API calls to the cluster API or when the ctx is Done().

func MonitorK8s

func MonitorK8s(ctx context.Context, errC chan<- kv.Error)

MonitorK8s is used to send appropriate errors into an error reporting channel on a regular basis if the k8s connectivity state changes

func StartPrometheusExporter

func StartPrometheusExporter(ctx context.Context, promAddr string, getRsc ResourceAvailable, update time.Duration, logger *log.Logger) (err kv.Error)

StartPrometheusExporter loops doing prometheus exports for resource consumption statistics etc on a regular basis

The update interval must be equal to or large than five seconds or an error will be returned

func StartTelemetry

func StartTelemetry(ctx context.Context, options StartTelemetryOpts, logger *log.Logger) (newCtx context.Context, err kv.Error)

StartTelemetry is used to initialize OpenTelemetry tracing, the ctx (context) is used to close the root span when the sever closes the channel. The options structure contains parameters for the OTel code.

Types

type K8sStateUpdate

type K8sStateUpdate struct {
	Name  string
	State types.K8sState
}

K8sStateUpdate encapsulates the known kubernetes state within which the server finds itself.

type Listeners

type Listeners struct {
	Master chan K8sStateUpdate

	sync.Mutex
	// contains filtered or unexported fields
}

Listeners is used to handle the broadcasting of cluster events when Kubernetes is being used

func K8sStateUpdates

func K8sStateUpdates() (l *Listeners)

func NewStateBroadcast

func NewStateBroadcast(ctx context.Context, errorC chan<- kv.Error) (l *Listeners)

NewStateBroadcast is used to instantiate a Kubernetes event broadcaster

func (*Listeners) Add

func (l *Listeners) Add(listen chan<- K8sStateUpdate) (id xid.ID, err kv.Error)

Add is used when a running thread wishes to add a channel to the broadcaster on which Kubernetes events will be received

func (*Listeners) Delete

func (l *Listeners) Delete(id xid.ID)

Delete is used when a running thread wishes to drop a channel from the broadcaster on which Kubernetes events will be received

type Resource

type Resource struct {
	Cpus     uint   `json:"cpus"`
	Gpus     uint   `json:"gpus"`
	Hdd      string `json:"hdd"`
	Ram      string `json:"ram"`
	GpuMem   string `json:"gpuMem"`
	GpuCount uint   `json:"gpuCount"`
}

Resource describes the needed resources for a runner task in a data structure that can be marshalled as json

func (*Resource) Clone

func (rsc *Resource) Clone() (r *Resource)

Clone will deep copy a resource and return the copy

func (*Resource) Fit

func (rsc *Resource) Fit(r *Resource) (didFit bool, err kv.Error)

Fit determines is a supplied resource description acting as a request can be satisfied by the receiver resource

Asks the question does rsc fit into r

func (Resource) String

func (rsc Resource) String() (serialized string)

type ResourceAvailable

type ResourceAvailable interface {
	FetchMachineResources() (rsc *Resource)
}

type Resources

type Resources struct{}

Resources is a receiver for resource related methods used to describe machine level capabilities

func (*Resources) FetchMachineResources

func (*Resources) FetchMachineResources() (rsc *Resource)

FetchMachineResources extracts the current system state in terms of memory etc and coverts this into the resource specification used to pass machine characteristics around.

type StartTelemetryOpts

type StartTelemetryOpts struct {
	NodeName    string           // Logical host name for OTel entries
	ServiceName string           //
	ProjectID   string           // A project identification string, typically the Go module name
	ApiKey      string           // The OTel server API key
	Dataset     string           // The OTel dataset identifier for all OTel information
	ApiEndpoint string           // The TCP/IP endpoint for the OTel server, or collector
	Cooldown    time.Duration    // The duration of time to wait after a termination signal is received to allow other modules to send events etc and end their own spans
	Bag         *baggage.Baggage // KV Pairs to propagate to all spans
}

StartTelemetryOpts is used to specify parameters for starting the OpenTelemetry module

Jump to

Keyboard shortcuts

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