base

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPidDirTemplate = "/var/run/$APPNAME"
View Source
const DefaultPidPathTemplate = "/var/run/$APPNAME/$APPNAME.pid"

Variables

This section is empty.

Functions

func FindAndShutdownTheRunningInstance

func FindAndShutdownTheRunningInstance(pfs PidFile) (err error)

FindAndShutdownTheRunningInstance locates the daemon process if running

func FindDaemonProcess

func FindDaemonProcess(pfs PidFile) (present bool, process *os.Process, err error)

FindDaemonProcess locates the daemon process if running

func IsPidFileExists

func IsPidFileExists(pfs PidFile) bool

IsPidFileExists checks if the pid file exists or not

Types

type Base

type Base struct {
	log.Logger
}

func NewBase

func NewBase() *Base

func NewBaseLogger

func NewBaseLogger(config *log.LoggerConfig) *Base

type CachedTCPWriter

type CachedTCPWriter interface {
	// WriteString send the string to the writing queue
	WriteString(message string)
	// Write send the buffer to the writing queue
	Write(message []byte)
}

type CachedUDPWriter

type CachedUDPWriter interface {
	WriteTo(remoteAddr *net.UDPAddr, data []byte)
}

type Config

type Config struct {
	LoggerConfig *log.LoggerConfig
	log.Logger

	Addr                string
	Uri                 *url.URL
	UriBase             string
	Adapter             string // network adapter name. such as "en4". default "". for udp multicast
	PrefixInCommandLine string
	PrefixInConfigFile  string
	PidDir              string

	Network              string
	TlsConfigInitializer tls2.Initializer
}

func NewConfigFromCmdrCommand

func NewConfigFromCmdrCommand(isServer bool, prefixPrefix string, cmd *cmdr.Command) *Config

func NewConfigWithParams

func NewConfigWithParams(isServer bool, netType, prefixPrefix, prefixCLI string, loggerConfig *log.LoggerConfig, tlsConfigInitializer tls2.Initializer, addr, uriBase, adapter string) *Config

func (*Config) BuildAddr

func (c *Config) BuildAddr() (err error)

func (*Config) BuildLogger

func (c *Config) BuildLogger()

func (*Config) BuildPidFileStruct

func (c *Config) BuildPidFileStruct() *pidFileStruct

func (*Config) BuildServerAddr

func (c *Config) BuildServerAddr() (err error)

func (*Config) BuildUriAddr

func (c *Config) BuildUriAddr(defaultPort string) (err error)

func (*Config) PressEnterToExit

func (c *Config) PressEnterToExit()

func (*Config) UpdatePrefixInConfigFile

func (c *Config) UpdatePrefixInConfigFile(s string)

type Conn

type Conn interface {
	Logger() log.Logger

	Close()

	RemoteAddr() net.Addr

	// RawWrite does write through the internal net.Conn
	RawWrite(ctx context.Context, message []byte) (n int, err error)
}

type PidFile

type PidFile interface {
	Path() string
	Create(baseCtx context.Context) (err error)
	Destroy()
	IsExists() bool
}

type UdpPacket

type UdpPacket struct {
	RemoteAddr *net.UDPAddr
	Data       []byte
}

func NewUdpPacket

func NewUdpPacket(remoteAddr *net.UDPAddr, data []byte) *UdpPacket

Jump to

Keyboard shortcuts

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