Documentation ¶
Index ¶
- Constants
- Variables
- func AddCA(tlsConf *tls.Config, caPath string) error
- func AddClientCA(tlsConf *tls.Config, clientCAPath string) error
- func BackgroundContext(ctx context.Context) context.Context
- func CreateView(measure stats.Measure, agg *view.Aggregation, tagKeys []string) *view.View
- func CreateViewWithTags(measure stats.Measure, agg *view.Aggregation, tags []tag.Key) *view.View
- func FnRequestID(ridFound string) string
- func GenerateLinearHistogramBuckets(min, max float64, count int) []float64
- func GenerateLogScaleHistogramBuckets(max float64, count int) []float64
- func GenerateLogScaleHistogramBucketsWithRange(min, max float64) []float64
- func GetEnv(key, fallback string) string
- func GetEnvDuration(key string, fallback time.Duration) time.Duration
- func GetEnvInt(key string, fallback int) int
- func IsDate(str string) bool
- func IsDateTime(str string) bool
- func IsTemporary(err error) bool
- func Logger(ctx context.Context) logrus.FieldLogger
- func LoggerWithFields(ctx context.Context, fields logrus.Fields) (context.Context, logrus.FieldLogger)
- func MakeKey(name string) tag.Key
- func MakeMeasure(name string, desc string, unit string) *stats.Int64Measure
- func MaskPassword(u *url.URL) string
- func MinDuration(f, s time.Duration) time.Duration
- func NewClampReadCloser(buf io.ReadCloser, max uint64, overflowErr error) io.ReadCloser
- func NewClampWriter(buf io.Writer, max uint64, overflowErr error) io.Writer
- func NewSyslogHook(url *url.URL, prefix string) error
- func NewTLSSimple(certPath, keyPath string) (*tls.Config, error)
- func RequestIDFromContext(ctx context.Context) string
- func SetLogDest(to, prefix string)
- func SetLogFormat(format string)
- func SetLogLevel(ll string)
- func StripHopHeaders(hdr http.Header)
- func WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context
- func WithRequestID(ctx context.Context, rid string) context.Context
- type BackOff
- type BackOffConfig
- type Clock
- type DateTime
- type GhostReader
- type GhostWriter
- type NoopReadWriteCloser
- type Temporary
- type Timer
- type WaitGroup
Constants ¶
const ( // RFC3339Millis represents a ISO8601 format to millis instead of to nanos RFC3339Millis = "2006-01-02T15:04:05.000Z07:00" // RFC3339Micro represents a ISO8601 format to micro instead of to nano RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00" // DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6 DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$` // RFC3339FullDate represents a full-date as specified by RFC3339 // See: http://goo.gl/xXOvVd RFC3339FullDate = "2006-01-02" )
const RequestIDContextKey = "fn_request_id"
RequestIDContextKey is the name of the key used to store the request ID into the context
const RetryForever uint64 = math.MaxUint64
Variables ¶
var ( // MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds) MarshalFormat = RFC3339Millis )
Functions ¶
func AddClientCA ¶
AddClientCA adds a client cert to the given tls config
func BackgroundContext ¶
BackgroundContext returns a context that is specifically not a child of the provided parent context wrt any cancellation or deadline of the parent, so that it contains all values only.
func CreateView ¶
func CreateViewWithTags ¶
func FnRequestID ¶
FnRequestID returns the passed value if that is not empty otherwise it generates a new unique ID
func GenerateLinearHistogramBuckets ¶ added in v0.3.731
GenerateLinearHistogramBuckets generates number of buckets specified by count in the range specified by min and max
func GenerateLogScaleHistogramBuckets ¶ added in v0.3.731
GenerateLogScaleHistogramBuckets generates number of buckets specified by count on the log scale such that the value specified by max is in the last bucket
func GenerateLogScaleHistogramBucketsWithRange ¶ added in v0.3.731
GenerateLogScaleHistogramBucketsWithRange generates histogram buckets on the log scale between the specified min and max range, such that the min value is in the first bucket and the max in the last.
func GetEnv ¶ added in v0.3.698
GetEnv looks up a key under its name in env or name+_FILE to read the value from a file. fallback will be defaulted to if a value is not found.
func GetEnvDuration ¶ added in v0.3.698
GetEnvDuration looks up a key under its name in env or name+_FILE to read the value from a file. fallback will be defaulted to if a value is not found. if an integer is provided, the value will be returned in seconds (value * time.Second)
func GetEnvInt ¶ added in v0.3.698
GetEnvInt looks up a key under its name in env or name+_FILE to read the value from a file. fallback will be defaulted to if a value is not found.
func IsDateTime ¶
IsDateTime returns true when the string is a valid date-time
func IsTemporary ¶
func Logger ¶
func Logger(ctx context.Context) logrus.FieldLogger
Logger returns the structured logger.
func LoggerWithFields ¶
func LoggerWithFields(ctx context.Context, fields logrus.Fields) (context.Context, logrus.FieldLogger)
LoggerWithFields returns a child context of the provided parent that contains a logger with additional fields from the parent's logger, it returns the new child logger, as well.
func MakeMeasure ¶
func MakeMeasure(name string, desc string, unit string) *stats.Int64Measure
func MaskPassword ¶
MaskPassword returns a stringified URL without its password visible
func NewClampReadCloser ¶
func NewClampReadCloser(buf io.ReadCloser, max uint64, overflowErr error) io.ReadCloser
func NewClampWriter ¶
NewClamWriter creates a clamp writer that will limit the number of bytes written to to an underlying stream This allows up to max bytes to be written to the underlying stream , writes that exceed this will return overflowErr
Setting a max of 0 sets no limit ¶
If a write spans the last remaining bytes available the number of bytes up-to the limit will be written and the overflow error will be returned
func NewTLSSimple ¶
NewTLSSimple creates a new tls config with the given cert and key file paths
func RequestIDFromContext ¶
RequestIDFromContext extract the request id from the context
func SetLogDest ¶
func SetLogDest(to, prefix string)
func SetLogFormat ¶
func SetLogFormat(format string)
func SetLogLevel ¶
func SetLogLevel(ll string)
func StripHopHeaders ¶ added in v0.3.702
StripHopHeaders removes transport related headers.
func WithLogger ¶
WithLogger stores the logger.
Types ¶
type BackOff ¶ added in v0.3.673
func NewBackOff ¶ added in v0.3.673
func NewBackOff(cfg BackOffConfig) BackOff
type BackOffConfig ¶ added in v0.3.673
type DateTime ¶
DateTime is a time but it serializes to ISO8601 format with millis It knows how to read 3 different variations of a RFC3339 date time. Most APIs we encounter want either millisecond or second precision times. This just tries to make it worry-free.
func NewDateTime ¶
func NewDateTime() DateTime
NewDateTime is a representation of zero value for DateTime type
func ParseDateTime ¶
ParseDateTime parses a string that represents an ISO8601 time or a unix epoch
func (DateTime) MarshalText ¶
MarshalText implements the text marshaller interface
func (*DateTime) UnmarshalText ¶
UnmarshalText implements the text unmarshaller interface
type GhostReader ¶
func NewGhostReader ¶
func NewGhostReader() GhostReader
type GhostWriter ¶
func NewGhostWriter ¶
func NewGhostWriter() GhostWriter
type NoopReadWriteCloser ¶ added in v0.3.618
type NoopReadWriteCloser struct{}
NoopReadWriteCloser implements io.ReadWriteCloser, discarding all bytes, Read always returns EOF
func (NoopReadWriteCloser) Close ¶ added in v0.3.618
func (n NoopReadWriteCloser) Close() error
Close implements io.Closer
type Timer ¶ added in v0.3.703
Timer is exactly the same semantics as time.Timer, except for Reset, which fixes a deficiency from the stdlib that would have resulted in our case as a desirable behavior change to fix. See Reset for details. NewTimer must be called in order to get a Timer or there will be panics.
func (*Timer) Reset ¶ added in v0.3.703
Reset behaves as both Stop and Reset, draining its channel before calling reset. It differs from the stdlib Timer.Reset by being safe to call on an 'active' timer, that is, a timer that has not yet fired. see https://golang.org/pkg/time/#Timer.Reset for more details. Reset must not be called while while any other goroutine is receiving from t.C.
type WaitGroup ¶
type WaitGroup struct {
// contains filtered or unexported fields
}
func NewWaitGroup ¶
func NewWaitGroup() *WaitGroup
func (*WaitGroup) AddSession ¶
AddSession manipulates the session counter by adding the delta value. Incrementing the session counter is not possible and will set return value to false if a close was initiated.
func (*WaitGroup) CloseGroup ¶
func (r *WaitGroup) CloseGroup()
CloseGroup initiates a close and blocks until session counter becomes zero.
func (*WaitGroup) CloseGroupNB ¶
func (r *WaitGroup) CloseGroupNB() chan struct{}
CloseGroupNB is non-blocking version of CloseGroup which returns a channel that can be waited on.
func (*WaitGroup) Closer ¶
func (r *WaitGroup) Closer() chan struct{}
Closer returns a channel that is closed if WaitGroup is in closing state
func (*WaitGroup) DoneSession ¶
func (r *WaitGroup) DoneSession()
DoneSession decrements 1 from accumulated sessions and wakes up listeners when this reaches zero.