runtime

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Runtime

A runtime for self governing services.

Overview

In recent years we've started to develop complex architectures for the pipeline between writing code and running it. This philosophy of build, run, manage or however many variations, has created a number of layers of abstraction that make it all the more difficult to run code.

Runtime manages the lifecycle of a service from source to running process. If the source is the source of truth then everything in between running is wasted breath. Applications should be self governing and self sustaining. To enable that we need libraries which make it possible.

Runtime will fetch source code, build a binary and execute it. Any Go program that uses this library should be able to run dependencies or itself with ease, with the ability to update itself as the source is updated.

Features

  • Source - Fetches source whether it be git, go, docker, etc
  • Package - Compiles the source into a binary which can be executed
  • Process - Executes a binary and creates a running process

Usage

TODO

Documentation

Overview

Package runtime is a service runtime manager

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultRuntime is default micro runtime
	DefaultRuntime Runtime = NewRuntime()
	// DefaultName is default runtime service name
	DefaultName = "go.micro.runtime"

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

Functions

This section is empty.

Types

type CreateOption

type CreateOption func(o *CreateOptions)

func CreateImage

func CreateImage(img string) CreateOption

CreateImage sets the image to use

func CreateType

func CreateType(t string) CreateOption

CreateType sets the type of service to create

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 attemps

type CreateOptions

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
}

CreateOptions configure runtime services

type Event

type Event struct {
	// Type is event type
	Type EventType
	// Timestamp is event timestamp
	Timestamp time.Time
	// Service is the name of the service
	Service string
	// Version of the build
	Version string
}

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

func (EventType) String

func (t EventType) String() string

String returns human readable event type

type Option

type Option func(o *Options)

func WithImage

func WithImage(t string) Option

WithImage sets the image to use

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 for updates
	Scheduler Scheduler
	// Service type to manage
	Type string
	// Source of the services repository
	Source string
	// Base image to use
	Image string
}

Options configure runtime

type ReadOption

type ReadOption func(o *ReadOptions)

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 {
	// Service name
	Service string
	// Version queries services with given version
	Version string
	// Type of service
	Type string
}

ReadOptions queries runtime services

type Runtime

type Runtime interface {
	// String describes runtime
	String() string
	// 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) error
	// Remove a service
	Delete(*Service) error
	// List the managed services
	List() ([]*Service, error)
	// Start starts the runtime
	Start() error
	// Stop shuts down the runtime
	Stop() error
}

Runtime is a service runtime manager

func NewRuntime

func NewRuntime(opts ...Option) Runtime

NewRuntime creates new local runtime and returns it

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 {
	// 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
}

Service is runtime service

Directories

Path Synopsis
Package kubernetes implements kubernetes micro runtime
Package kubernetes implements kubernetes micro runtime
Package local provides a local runtime
Package local provides a local runtime
build
Package build builds a micro runtime package
Package build builds a micro runtime package
build/docker
Package docker builds docker images
Package docker builds docker images
build/go
Package golang is a go package manager
Package golang is a go package manager
process
Package process executes a binary
Package process executes a binary
process/os
Package os runs processes locally Package os runs processes locally
Package os runs processes locally Package os runs processes locally
source
Package source retrieves source code
Package source retrieves source code
source/git
Package git provides a git source
Package git provides a git source
source/go
Package golang is a source for Go
Package golang is a source for Go

Jump to

Keyboard shortcuts

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