zerodt

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: MIT Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ZeroDT Build Status

Zero downtime restart and graceful shutdown in one line of code

  • TODO: errors in a separate channel
  • TODO: prestart handler
  • TODO: build on Win
  • TODO: tests
  • TODO: travis
  • TODO: doc.go #godoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l StdLogger)

SetLogger allows to set a different logger that is compatible with StdLogger interface. Tested with stdlib logger:

log.New(os.Stderr, "", log.LstdFlags)

And sirupsen/logrus:

logrus.StandardLogger()

Types

type App

type App struct {
	WaitForParentTimeout time.Duration
	WaitForChildTimeout  time.Duration
	// contains filtered or unexported fields
}

App TODO

func NewApp

func NewApp(servers ...*http.Server) *App

NewApp TODO

func (*App) Serve

func (a *App) Serve() error

Serve TODO

type StdLogger

type StdLogger interface {
	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})

	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Fatalln(...interface{})

	Panic(...interface{})
	Panicf(string, ...interface{})
	Panicln(...interface{})
}

StdLogger is an interface for stdlib logger also compatible with logrus

type StreamMessenger

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

StreamMessenger a simple messenger based on net.Conn. A simplest way to create messenger is to use syscall.Socketpair():

fds, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_STREAM, 0)
f0 := os.NewFile(uintptr(fds[0]), "s|0")
f1 := os.NewFile(uintptr(fds[1]), "s|1")

m0, err := ListenSocket(f0)
m1, err := ListenSocket(f1)

Packet format: +-----------------------+---------+ | Header (8 bytes) | Payload | +-----------------------+---------+ | MagicN | Payload Size | Payload | +-----------------------+---------+

func ListenSocket

func ListenSocket(s *os.File) (*StreamMessenger, error)

ListenSocket TODO

func (*StreamMessenger) Close

func (m *StreamMessenger) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*StreamMessenger) Recv

func (m *StreamMessenger) Recv(v interface{}) (err error)

Recv receives a message from the channel.

func (*StreamMessenger) Send

func (m *StreamMessenger) Send(v interface{}) error

Send sends a message to the channel.

func (*StreamMessenger) SetDeadline

func (m *StreamMessenger) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (*StreamMessenger) SetReadDeadline

func (m *StreamMessenger) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.

func (*StreamMessenger) SetWriteDeadline

func (m *StreamMessenger) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

Directories

Path Synopsis
examples
test command

Jump to

Keyboard shortcuts

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