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 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 NewRNG(seed int64) *rand.Rand
- 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 WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context
- func WithRequestID(ctx context.Context, rid string) context.Context
- type Backoff
- type BoxTime
- type Clock
- type DateTime
- type GhostReader
- type GhostWriter
- type NoopReadWriteCloser
- type Temporary
- 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
Variables ¶
var ( // MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds) MarshalFormat = RFC3339Millis )
Functions ¶
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 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 NewTLSSimple ¶
A simple TLS Config generator using cert/key
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 WithLogger ¶
WithLogger stores the logger.
Types ¶
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 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.