continuous

package module
v0.0.0-...-acf2009 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 16 Imported by: 4

README

Continuous

Build Status

Continuous is a framework to upgrade a daemon binary without interrupt

Features

  • Emigrate listen fds
  • Flexible controlling on multiple phases
  • Graceful stop or force stop the old service
  • Rollback to the old service

Demo

source code

TODO

  • Add unittests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cont

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

Cont keeps your server which implement the Continuous continuously

func New

func New(opts ...Option) *Cont

New creates a Cont object which upgrades binary continuously

func (*Cont) AddServer

func (cont *Cont) AddServer(srv Continuous, listenOn *ListenOn, opts ...ServerOption) error

AddServer and a server which implement Continuous interface the added server will start to listen to the socket, but it only accept connections after serving

func (*Cont) GracefulStop

func (cont *Cont) GracefulStop() error

GracefulStop the server

func (*Cont) Serve

func (cont *Cont) Serve() error

Serve run all the servers and wait to handle signals

func (*Cont) Status

func (cont *Cont) Status() ContState

Status return the current status

func (*Cont) Stop

func (cont *Cont) Stop() error

Stop the server immediately

type ContServer

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

ContServer combines listener, addresss and a continuous

type ContState

type ContState int

ContState indicates the state of Cont

const (
	Running ContState = iota
	Ready
	Stopped
)

func (ContState) String

func (cs ContState) String() string

type Continuous

type Continuous interface {
	Serve(lis net.Listener) error
	Stop() error
	GracefulStop() error
}

Continuous is the interface of a basic server

func WrapGRPCServer

func WrapGRPCServer(s *grpc.Server) Continuous

func WrapHTTPServer

func WrapHTTPServer(s *http.Server) Continuous

func WrapHTTPServerTLS

func WrapHTTPServerTLS(s *http.Server, certFile, keyFile string) Continuous

type ListenOn

type ListenOn struct {
	Network string
	Address string
}

ListenOn some network and address

type Option

type Option func(cont *Cont)

Option to new a Cont

func LoggerOutput

func LoggerOutput(out io.Writer) Option

LoggerOutput sets a io.Writer to output log

func PidFile

func PidFile(filename string) Option

PidFile custom the pid file path

func ProcName

func ProcName(name string) Option

ProcName custom the procname, use os.Args[0] if not set

func WorkDir

func WorkDir(path string) Option

WorkDir custom the work dir, use os.Getwd() if not set

type ServerOption

type ServerOption func(cs *ContServer)

func ListenerUpgrader

func ListenerUpgrader(upgrader func(lis net.Listener) net.Listener) ServerOption

ListenerUpgrader upgrade a raw listener to a higher level listener

func TLSConfig

func TLSConfig(c *tls.Config) ServerOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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