timesync

package
v0.0.0-...-f2d3015 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimesyncLeaderMagic   = 0x71DE7EAD
	TimesyncFollowerMagic = 0x71DEF011
)

Variables

This section is empty.

Functions

func DecodeTimesyncRequests

func DecodeTimesyncRequests(r io.Reader) <-chan TimesyncRequest

func EncodeTimesyncReplies

func EncodeTimesyncReplies(w io.Writer) chan<- TimesyncReply

func EncodeTimesyncReply

func EncodeTimesyncReply(w io.Writer, reply TimesyncReply) error

func HandleTimesyncProtocol

func HandleTimesyncProtocol(ctx context.Context, conn net.Conn, impl ProtocolImpl) error

func ListenSingleConnection

func ListenSingleConnection(ctx context.Context, sockpath string) (net.Conn, error)

func ListenUnix

func ListenUnix(ctx context.Context, sockpath string) (<-chan net.Conn, error)

func OnCancel

func OnCancel(ctx context.Context, cb func())

func OnInterrupt

func OnInterrupt(ctx context.Context, cb func())

func Simple

func Simple(sockpath string, app ProtocolImpl) error

Types

type ProtocolImpl

type ProtocolImpl interface {
	Sync(pendingReadBytes int, now int64, writeData []byte) (expireAt int64, readData []byte)
}

type TimesyncReply

type TimesyncReply struct {
	SeqNum   uint32
	ExpireAt int64
	Data     []byte
}

type TimesyncRequest

type TimesyncRequest struct {
	SeqNum           uint32
	PendingReadBytes uint32
	Now              int64
	Data             []byte
}

func DecodeTimesyncRequest

func DecodeTimesyncRequest(r io.Reader) (TimesyncRequest, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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