go-micro: github.com/micro/go-micro/runtime Index | Files | Directories

package runtime

import "github.com/micro/go-micro/runtime"

Package runtime is a service runtime manager

Index

Package Files

options.go runtime.go

Variables

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

type CreateOption Uses

type CreateOption func(o *CreateOptions)

func CreateContext Uses

func CreateContext(ctx context.Context) CreateOption

CreateContext sets the context

func CreateImage Uses

func CreateImage(img string) CreateOption

CreateImage sets the image to use

func CreateNamespace Uses

func CreateNamespace(ns string) CreateOption

CreateNamespace sets the namespace

func CreateType Uses

func CreateType(t string) CreateOption

CreateType sets the type of service to create

func ResourceLimits Uses

func ResourceLimits(r *Resources) CreateOption

ResourceLimits sets the resources for the service to use

func WithArgs Uses

func WithArgs(args ...string) CreateOption

WithArgs specifies the command to execute

func WithCommand Uses

func WithCommand(cmd ...string) CreateOption

WithCommand specifies the command to execute

func WithEnv Uses

func WithEnv(env []string) CreateOption

WithEnv sets the created service environment

func WithOutput Uses

func WithOutput(out io.Writer) CreateOption

WithOutput sets the arg output

func WithRetries Uses

func WithRetries(retries int) CreateOption

WithRetries sets the max retries attemps

func WithSecret Uses

func WithSecret(key, value string) CreateOption

WithSecret sets a secret to provide the service with

type CreateOptions Uses

type CreateOptions struct {
    // Command to execut
    Command []string
    // Args to pass into command
    Args []string
    // Environment to configure
    Env []string
    // Log output
    Output io.Writer
    // Type of service to create
    Type string
    // Retries before failing deploy
    Retries int
    // Specify the image to use
    Image string
    // Namespace to create the service in
    Namespace string
    // Specify the context to use
    Context context.Context
    // Secrets to use
    Secrets map[string]string
    // Resources to allocate the service
    Resources *Resources
}

CreateOptions configure runtime services

type DeleteOption Uses

type DeleteOption func(o *DeleteOptions)

func DeleteContext Uses

func DeleteContext(ctx context.Context) DeleteOption

DeleteContext sets the context

func DeleteNamespace Uses

func DeleteNamespace(ns string) DeleteOption

DeleteNamespace sets the namespace

type DeleteOptions Uses

type DeleteOptions struct {
    // Namespace the service is running in
    Namespace string
    // Specify the context to use
    Context context.Context
}

type Event Uses

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

Event is notification event

type EventType Uses

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
    Update
    // Delete is emitted when a build has been deleted
    Delete
)

func (EventType) String Uses

func (t EventType) String() string

String returns human readable event type

type Log Uses

type Log struct {
    Message  string
    Metadata map[string]string
}

Log is a log message

type Logs Uses

type Logs interface {
    Error() error
    Chan() chan Log
    Stop() error
}

Logs returns a log stream

type LogsOption Uses

type LogsOption func(o *LogsOptions)

LogsOption configures runtime logging

func LogsContext Uses

func LogsContext(ctx context.Context) LogsOption

LogsContext sets the context

func LogsCount Uses

func LogsCount(count int64) LogsOption

LogsExistingCount confiures how many existing lines to show

func LogsNamespace Uses

func LogsNamespace(ns string) LogsOption

LogsNamespace sets the namespace

func LogsStream Uses

func LogsStream(stream bool) LogsOption

LogsStream configures whether to stream new lines

type LogsOptions Uses

type LogsOptions struct {
    // How many existing lines to show
    Count int64
    // Stream new lines?
    Stream bool
    // Namespace the service is running in
    Namespace string
    // Specify the context to use
    Context context.Context
}

LogsOptions configure runtime logging

type Option Uses

type Option func(o *Options)

func WithClient Uses

func WithClient(c client.Client) Option

WithClient sets the client to use

func WithImage Uses

func WithImage(t string) Option

WithImage sets the image to use

func WithScheduler Uses

func WithScheduler(n Scheduler) Option

WithScheduler specifies a scheduler for updates

func WithSource Uses

func WithSource(src string) Option

WithSource sets the base image / repository

func WithType Uses

func WithType(t string) Option

WithType sets the service type to manage

type Options Uses

type Options struct {
    // Scheduler for updates
    Scheduler Scheduler
    // Service type to manage
    Type string
    // Source of the services repository
    Source string
    // Base image to use
    Image string
    // Client to use when making requests
    Client client.Client
}

Options configure runtime

type ReadOption Uses

type ReadOption func(o *ReadOptions)

func ReadContext Uses

func ReadContext(ctx context.Context) ReadOption

ReadContext sets the context

func ReadNamespace Uses

func ReadNamespace(ns string) ReadOption

ReadNamespace sets the namespace

func ReadService Uses

func ReadService(service string) ReadOption

ReadService returns services with the given name

func ReadType Uses

func ReadType(t string) ReadOption

ReadType returns services of the given type

func ReadVersion Uses

func ReadVersion(version string) ReadOption

ReadVersion confifgures service version

type ReadOptions Uses

type ReadOptions struct {
    // Service name
    Service string
    // Version queries services with given version
    Version string
    // Type of service
    Type string
    // Namespace the service is running in
    Namespace string
    // Specify the context to use
    Context context.Context
}

ReadOptions queries runtime services

type Resources Uses

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 Uses

type Runtime interface {
    // Init initializes runtime
    Init(...Option) error
    // CreateNamespace creates a new namespace in the runtime
    CreateNamespace(string) error
    // DeleteNamespace deletes a namespace in the runtime
    DeleteNamespace(string) 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 defines the runtime implementation
    String() string
}

Runtime is a service runtime manager

type Scheduler Uses

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 Uses

type Service struct {
    // Name of the service
    Name string
    // Version of the service
    Version string
    // url location of source
    Source string
    // Metadata stores metadata
    Metadata map[string]string
    // Status of the service
    Status ServiceStatus
}

Service is runtime service

type ServiceStatus Uses

type ServiceStatus int

ServiceStatus defines service statuses

const (
    // Unknown indicates the status of the service is not known
    Unknown ServiceStatus = iota
    // Pending is the initial status of a service
    Pending
    // Building is the status when the service is being built
    Building
    // Starting is the status when the service has been started but is not yet ready to accept traffic
    Starting
    // Running is the status when the service is active and accepting traffic
    Running
    // Stopping is the status when a service is stopping
    Stopping
    // Stopped is the status when a service has been stopped or has completed
    Stopped
    // Error is the status when an error occured, this could be a build error or a run error. The error
    // details can be found within the service's metadata
    Error
)

type UpdateOption Uses

type UpdateOption func(o *UpdateOptions)

func UpdateContext Uses

func UpdateContext(ctx context.Context) UpdateOption

UpdateContext sets the context

func UpdateNamespace Uses

func UpdateNamespace(ns string) UpdateOption

UpdateNamespace sets the namespace

func UpdateSecret Uses

func UpdateSecret(key, value string) UpdateOption

WithSecret sets a secret to provide the service with

type UpdateOptions Uses

type UpdateOptions struct {
    // Namespace the service is running in
    Namespace string
    // Specify the context to use
    Context context.Context
    // Secrets to use
    Secrets map[string]string
}

Directories

PathSynopsis
kubernetesPackage kubernetes implements kubernetes micro runtime
localPackage local provides a local runtime
local/build/dockerPackage docker builds docker images
local/build/goPackage golang is a go package manager
local/git
local/processPackage process executes a binary
local/process/osPackage os runs processes locally
local/sourcePackage source retrieves source code
local/source/git
local/source/goPackage golang is a source for Go

Package runtime imports 5 packages (graph) and is imported by 7 packages. Updated 2020-09-20. Refresh now. Tools for package owners.