gracenet

package
Version: v0.0.0-...-75cf193 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: MIT Imports: 7 Imported by: 37

Documentation

Overview

Package gracenet provides a family of Listen functions that either open a fresh connection or provide an inherited connection from when the process was started. The behave like their counterparts in the net package, but transparently provide support for graceful restarts without dropping connections. This is provided in a systemd socket activation compatible form to allow using socket activation.

BUG: Doesn't handle closing of listeners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Net

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

Net provides the family of Listen functions and maintains the associated state. Typically you will have only once instance of Net per application.

func (*Net) Listen

func (n *Net) Listen(nett, laddr string) (net.Listener, error)

Listen announces on the local network address laddr. The network net must be a stream-oriented network: "tcp", "tcp4", "tcp6", "unix" or "unixpacket". It returns an inherited net.Listener for the matching network and address, or creates a new one using net.Listen.

func (*Net) ListenTCP

func (n *Net) ListenTCP(nett string, laddr *net.TCPAddr) (*net.TCPListener, error)

ListenTCP announces on the local network address laddr. The network net must be: "tcp", "tcp4" or "tcp6". It returns an inherited net.Listener for the matching network and address, or creates a new one using net.ListenTCP.

func (*Net) ListenUnix

func (n *Net) ListenUnix(nett string, laddr *net.UnixAddr) (*net.UnixListener, error)

ListenUnix announces on the local network address laddr. The network net must be a: "unix" or "unixpacket". It returns an inherited net.Listener for the matching network and address, or creates a new one using net.ListenUnix.

func (*Net) StartProcess

func (n *Net) StartProcess() (int, error)

StartProcess starts a new process passing it the active listeners. It doesn't fork, but starts a new process using the same environment and arguments as when it was originally started. This allows for a newly deployed binary to be started. It returns the pid of the newly started process when successful.

Source Files

Jump to

Keyboard shortcuts

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