kronosutil

package
v0.0.0-...-2c42c2a Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CACert is the file name for CA certificate
	CACert = "ca.crt"
	// NodeCert is the file name for Node certificate
	NodeCert = "node.crt"
	// NodeKey is the file name for Node Key
	NodeKey = "node.key"
)

Variables

This section is empty.

Functions

func AddToURLPath

func AddToURLPath(baseURL url.URL, path string) url.URL

AddToURLPath resolves baseURL to the given path.

func AddrToURL

func AddrToURL(addr *kronospb.NodeAddr, secure bool) url.URL

AddrToURL converts kronos NodeAddr to http URL

func CloseWithErrorLog

func CloseWithErrorLog(ctx context.Context, o io.Closer)

CloseWithErrorLog closes the given closer and logs the error. There are lint checks which prevent defer close() if close() returns an error, this closer is useful in such cases.

func NodeAddr

func NodeAddr(addr string) (*kronospb.NodeAddr, error)

NodeAddr converts address in host:port format to NodeAddr.

func NodeAddrToString

func NodeAddrToString(addr *kronospb.NodeAddr) string

NodeAddrToString joins host and port and returns the address in the form of "127.0.0.1:5766"

func SSLCreds

func SSLCreds(certsDir string) (credentials.TransportCredentials, error)

SSLCreds returns credentials by reading keys and certificates from certsDir

func TLSInfo

func TLSInfo(certsDir string) transport.TLSInfo

TLSInfo returns the tlsInfo with certificates in the certsDir. if certsDir is empty, it returns empty tlsInfo.

func ValidateTimeInConsensus

func ValidateTimeInConsensus(
	ctx context.Context, maxDiffAllowed time.Duration, timeOnNodes map[string]int64,
) error

ValidateTimeInConsensus validates that the kronos time across the given nodes (difference between maxTime and minTime) is within maxDiffAllowed.

Types

type StoppableListener

type StoppableListener struct {
	*net.TCPListener
	// contains filtered or unexported fields
}

StoppableListener sets TCP keep-alive timeouts on accepted connections. It stops listening when stopC is closed.

func NewStoppableListener

func NewStoppableListener(addr string, stopc <-chan struct{}) (*StoppableListener, error)

NewStoppableListener returns an instance of StoppableListener

func (StoppableListener) Accept

func (ln StoppableListener) Accept() (c net.Conn, err error)

Accept listens to and accepts TCP connections It returns the connection accepted

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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