Documentation ¶
Index ¶
- Constants
- Variables
- func BridgeConns(c1 io.ReadWriteCloser, c1Name string, c2 io.ReadWriteCloser, c2Name string, ...)
- func ErrorIsKind(err error, kind string) bool
- func GetSysCPUCount() int
- func GetSysMemoryMiB() uint64
- func MakeReceptorSAN(dnsNames []string, ipAddresses []net.IP, nodeIDs []string) (*pkix.Extension, error)
- func ParseReceptorNamesFromCert(cert *x509.Certificate, expectedHostname string, logger *logger.ReceptorLogger) (bool, []string, error)
- func ReadStringContext(ctx context.Context, reader *bufio.Reader, delim byte) (string, error)
- func ReceptorNames(extensions []pkix.Extension) ([]string, error)
- type Broker
- type DNSNameEncode
- type ErrorWithKind
- type FLock
- type GeneralNameEncode
- type IPAddressEncode
- type IncrementalDuration
- type JobContext
- func (mw *JobContext) Cancel()
- func (mw *JobContext) Deadline() (time time.Time, ok bool)
- func (mw *JobContext) Done() <-chan struct{}
- func (mw *JobContext) Err() error
- func (mw *JobContext) NewJob(ctx context.Context, workers int, returnIfRunning bool) bool
- func (mw *JobContext) Running() bool
- func (mw *JobContext) Value(key interface{}) interface{}
- func (mw *JobContext) Wait()
- func (mw *JobContext) WorkerDone()
- type OtherNameDecode
- type OtherNameEncode
- type UTFString
Constants ¶
const NormalBufferSize = 65536
NormalBufferSize is the size of buffers used by various processes when copying data between sockets.
Variables ¶
var ( // OIDSubjectAltName is the OID for subjectAltName. OIDSubjectAltName = asn1.ObjectIdentifier{2, 5, 29, 17} // OIDReceptorName is the OID for a Receptor node ID. OIDReceptorName = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 2312, 19, 1} )
var ErrLocked = fmt.Errorf("fslock is already locked")
ErrLocked is returned when the flock is already held.
Functions ¶
func BridgeConns ¶
func BridgeConns(c1 io.ReadWriteCloser, c1Name string, c2 io.ReadWriteCloser, c2Name string, logger *logger.ReceptorLogger)
BridgeConns bridges two connections, like netcat.
func ErrorIsKind ¶
ErrorIsKind returns true if err is an ErrorWithKind of the specified kind, or false otherwise (including if nil).
func GetSysCPUCount ¶
func GetSysCPUCount() int
GetSysCPUCount returns number of logical CPU cores on the system.
func GetSysMemoryMiB ¶
func GetSysMemoryMiB() uint64
GetSysMemoryMiB returns the capacity (in mebibytes) of the physical memory installed on the system.
func MakeReceptorSAN ¶
func MakeReceptorSAN(dnsNames []string, ipAddresses []net.IP, nodeIDs []string) (*pkix.Extension, error)
MakeReceptorSAN generates a subjectAltName extension, optionally containing Receptor names.
func ParseReceptorNamesFromCert ¶ added in v1.3.0
func ParseReceptorNamesFromCert(cert *x509.Certificate, expectedHostname string, logger *logger.ReceptorLogger) (bool, []string, error)
func ReadStringContext ¶
ReadStringContext calls bufio.Reader.ReadString() but uses a context. Note that if the ctx.Done() fires, the ReadString() call is still active, and bufio is not re-entrant, so it is important for callers to error out of further use of the bufio. Also, the goroutine will not exit until the bufio's underlying connection is closed.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker implements a simple pub-sub broadcast system.
func (*Broker) Subscribe ¶
func (b *Broker) Subscribe() chan interface{}
Subscribe registers to receive messages from the broker.
func (*Broker) Unsubscribe ¶
func (b *Broker) Unsubscribe(msgCh chan interface{})
Unsubscribe de-registers a message receiver.
type DNSNameEncode ¶
type DNSNameEncode struct {
Value string `asn1:"tag:2"`
}
DNSNameEncode is used for encoding the OtherName field of an x.509 subjectAltName.
type ErrorWithKind ¶
ErrorWithKind represents an error wrapped with a designation of what kind of error it is.
func WrapErrorWithKind ¶
func WrapErrorWithKind(err error, kind string) ErrorWithKind
WrapErrorWithKind creates an ErrorWithKind that wraps an underlying error.
func (ErrorWithKind) Error ¶
func (ek ErrorWithKind) Error() string
Error returns the error text as a string.
type FLock ¶
type FLock struct {
Fd int
}
FLock represents a file lock.
func UnixSocketListen ¶
UnixSocketListen listens on a Unix socket, handling file locking and permissions.
type GeneralNameEncode ¶
type GeneralNameEncode struct {
Names []interface{} `asn1:"tag:0"`
}
GeneralNameEncode is used for encoding a GeneralName in an x.509 certificate.
type IPAddressEncode ¶
type IPAddressEncode struct {
Value []byte `asn1:"tag:7"`
}
IPAddressEncode is used for encoding the OtherName field of an x.509 subjectAltName.
type IncrementalDuration ¶
type IncrementalDuration struct { Duration time.Duration InitialDuration time.Duration MaxDuration time.Duration // contains filtered or unexported fields }
IncrementalDuration handles a time.Duration with max limits.
func NewIncrementalDuration ¶
func NewIncrementalDuration(duration, maxDuration time.Duration, multiplier float64) *IncrementalDuration
NewIncrementalDuration returns an IncrementalDuration object with initialized values.
func (*IncrementalDuration) IncreaseDuration ¶ added in v1.4.9
func (id *IncrementalDuration) IncreaseDuration()
func (*IncrementalDuration) NextTimeout ¶
func (id *IncrementalDuration) NextTimeout() <-chan time.Time
NextTimeout returns a timeout channel based on current duration.
func (*IncrementalDuration) Reset ¶
func (id *IncrementalDuration) Reset()
Reset sets current duration to initial duration.
type JobContext ¶
type JobContext struct { Ctx context.Context JcCancel context.CancelFunc Wg *sync.WaitGroup JcRunning bool RunningLock *sync.Mutex }
JobContext is a synchronization object that combines the functions of a Context and a WaitGroup. The expected lifecycle is:
- Caller calls JobContext.NewJob() with a parent context and a count of workers expected.
- Caller launches the given number of workers, passing the JobContext to them.
- Workers can check for termination by using the JobContext as a context.Context.
- Workers can cancel the overall job by calling JobContext.Cancel().
- Workers must call JobContext.WorkerDone() when they complete, like sync.WaitGroup.Done().
- The caller, or other goroutines. can call JobContext.Wait() to wait for job completion.
A single JobContext can only run one job at a time. If JobContext.NewJob() is called while a job is already running, that job will be cancelled and waited on prior to starting the new job.
func (*JobContext) Cancel ¶
func (mw *JobContext) Cancel()
Cancel cancels the JobContext's context. If no job has been started, this does nothing.
func (*JobContext) Deadline ¶
func (mw *JobContext) Deadline() (time time.Time, ok bool)
Deadline implements Context.Deadline().
func (*JobContext) Done ¶
func (mw *JobContext) Done() <-chan struct{}
Done implements Context.Done().
func (*JobContext) NewJob ¶
NewJob starts a new job with a defined number of workers. If a prior job is running, it is cancelled.
func (*JobContext) Running ¶
func (mw *JobContext) Running() bool
Running returns true if a job is currently running.
func (*JobContext) Value ¶
func (mw *JobContext) Value(key interface{}) interface{}
Value implements Context.Value().
func (*JobContext) Wait ¶
func (mw *JobContext) Wait()
Wait waits for the current job to complete, like sync.WaitGroup.Wait(). If no job has been started, always just returns.
func (*JobContext) WorkerDone ¶
func (mw *JobContext) WorkerDone()
WorkerDone signals that a worker is finished, like sync.WaitGroup.Done().
type OtherNameDecode ¶
type OtherNameDecode struct { ID asn1.ObjectIdentifier Value asn1.RawValue }
OtherNameDecode is used for decoding the OtherName field type of an x.509 subjectAltName.
type OtherNameEncode ¶
type OtherNameEncode struct { OID asn1.ObjectIdentifier Value UTFString `asn1:"tag:0"` }
OtherNameEncode is used for encoding the OtherName field of an x.509 subjectAltName.