Version: v3.7.4 Latest Latest

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 1



Package runtime is a service runtime manager



This section is empty.


View Source
var ErrAlreadyExists = errors.New("already exists")

ErrAlreadyExists error


This section is empty.


type CreateOption

type CreateOption func(o *CreateOptions)

CreateOption func signature

func CreateContext

func CreateContext(ctx context.Context) CreateOption

CreateContext sets the context

func CreateImage

func CreateImage(img string) CreateOption

CreateImage sets the image to use

func CreateNamespace

func CreateNamespace(ns string) CreateOption

CreateNamespace sets the namespace

func CreateType

func CreateType(t string) CreateOption

CreateType sets the type of service to create

func ResourceLimits

func ResourceLimits(r *Resources) CreateOption

ResourceLimits sets the resources for the service to use

func WithArgs

func WithArgs(args ...string) CreateOption

WithArgs specifies the command to execute

func WithCommand

func WithCommand(cmd ...string) CreateOption

WithCommand specifies the command to execute

func WithEnv

func WithEnv(env []string) CreateOption

WithEnv sets the created service environment

func WithOutput

func WithOutput(out io.Writer) CreateOption

WithOutput sets the arg output

func WithRetries

func WithRetries(retries int) CreateOption

WithRetries sets the max retries attempts

func WithSecret

func WithSecret(key, value string) CreateOption

WithSecret sets a secret to provide the service with

type CreateOptions

type CreateOptions struct {
	Context   context.Context
	Output    io.Writer
	Resources *Resources
	Secrets   map[string]string
	Image     string
	Namespace string
	Type      string
	Command   []string
	Args      []string
	Env       []string
	Retries   int

CreateOptions configure runtime services

type DeleteOption

type DeleteOption func(o *DeleteOptions)

DeleteOption func signature

func DeleteContext

func DeleteContext(ctx context.Context) DeleteOption

DeleteContext sets the context

func DeleteNamespace

func DeleteNamespace(ns string) DeleteOption

DeleteNamespace sets the namespace

type DeleteOptions

type DeleteOptions struct {
	Context   context.Context
	Namespace string

DeleteOptions struct

type Event

type Event struct {
	// Timestamp of event
	Timestamp time.Time
	// Service the event relates to
	Service *Service
	// Options to use when processing the event
	Options *CreateOptions
	// ID of the event
	ID string
	// Type is event type
	Type EventType

Event is notification event

type EventType

type EventType int

EventType defines schedule event

const (
	// Create is emitted when a new build has been craeted
	Create EventType = iota
	// Update is emitted when a new update become available
	// Delete is emitted when a build has been deleted

func (EventType) String

func (t EventType) String() string

String returns human readable event type

type Log

type Log struct {
	// Metadata holds metadata
	Metadata metadata.Metadata
	// Message holds the message
	Message string

Log is a log message

type Logs

type Logs interface {
	// Error returns error
	Error() error
	// Chan return chan log
	Chan() chan Log
	// Stop stops the log stream
	Stop() error

Logs returns a log stream

type LogsOption

type LogsOption func(o *LogsOptions)

LogsOption configures runtime logging

func LogsContext

func LogsContext(ctx context.Context) LogsOption

LogsContext sets the context

func LogsCount

func LogsCount(count int64) LogsOption

LogsCount confiures how many existing lines to show

func LogsNamespace

func LogsNamespace(ns string) LogsOption

LogsNamespace sets the namespace

func LogsStream

func LogsStream(stream bool) LogsOption

LogsStream configures whether to stream new lines

type LogsOptions

type LogsOptions struct {
	Context   context.Context
	Namespace string
	Count     int64
	Stream    bool

LogsOptions configure runtime logging

type Option

type Option func(o *Options)

Option func signature

func WithClient

func WithClient(c client.Client) Option

WithClient sets the client to use

func WithImage

func WithImage(t string) Option

WithImage sets the image to use

func WithLogger

func WithLogger(l logger.Logger) Option

WithLogger sets the logger

func WithScheduler

func WithScheduler(n Scheduler) Option

WithScheduler specifies a scheduler for updates

func WithSource

func WithSource(src string) Option

WithSource sets the base image / repository

func WithType

func WithType(t string) Option

WithType sets the service type to manage

type Options

type Options struct {
	Scheduler Scheduler
	Client    client.Client
	Logger    logger.Logger
	Type      string
	Source    string
	Image     string

Options configure runtime

type ReadOption

type ReadOption func(o *ReadOptions)

ReadOption func signature

func ReadContext

func ReadContext(ctx context.Context) ReadOption

ReadContext sets the context

func ReadNamespace

func ReadNamespace(ns string) ReadOption

ReadNamespace sets the namespace

func ReadService

func ReadService(service string) ReadOption

ReadService returns services with the given name

func ReadType

func ReadType(t string) ReadOption

ReadType returns services of the given type

func ReadVersion

func ReadVersion(version string) ReadOption

ReadVersion confifgures service version

type ReadOptions

type ReadOptions struct {
	Context   context.Context
	Service   string
	Version   string
	Type      string
	Namespace string

ReadOptions queries runtime services

type Resources

type Resources struct {
	// CPU is the maximum amount of CPU the service will be allocated (unit millicpu)
	// e.g. 0.25CPU would be passed as 250
	CPU int
	// Mem is the maximum amount of memory the service will be allocated (unit mebibyte)
	// e.g. 128 MiB of memory would be passed as 128
	Mem int
	// Disk is the maximum amount of disk space the service will be allocated (unit mebibyte)
	// e.g. 128 MiB of memory would be passed as 128
	Disk int

Resources which are allocated to a serivce

type Runtime

type Runtime interface {
	// Init initializes runtime
	Init(...Option) error
	// Create registers a service
	Create(*Service, ...CreateOption) error
	// Read returns the service
	Read(...ReadOption) ([]*Service, error)
	// Update the service in place
	Update(*Service, ...UpdateOption) error
	// Remove a service
	Delete(*Service, ...DeleteOption) error
	// Logs returns the logs for a service
	Logs(*Service, ...LogsOption) (Logs, error)
	// Start starts the runtime
	Start() error
	// Stop shuts down the runtime
	Stop() error
	// String describes runtime
	String() string

Runtime is a service runtime manager

type Scheduler

type Scheduler interface {
	// Notify publishes schedule events
	Notify() (<-chan Event, error)
	// Close stops the scheduler
	Close() error

Scheduler is a runtime service scheduler

type Service

type Service struct {
	// Metadata stores metadata
	Metadata metadata.Metadata
	// Name of the service
	Name string
	// Version of the service
	Version string
	// Name of the service
	Source string

Service is runtime service

type UpdateOption

type UpdateOption func(o *UpdateOptions)

UpdateOption func signature

func UpdateContext

func UpdateContext(ctx context.Context) UpdateOption

UpdateContext sets the context

func UpdateNamespace

func UpdateNamespace(ns string) UpdateOption

UpdateNamespace sets the namespace

func UpdateSecret

func UpdateSecret(key, value string) UpdateOption

UpdateSecret sets a secret to provide the service with

type UpdateOptions

type UpdateOptions struct {
	Context   context.Context
	Secrets   map[string]string
	Namespace string

UpdateOptions struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL