Documentation
¶
Index ¶
- Variables
- func NewLogrusBufferHook(levels []logrus.Level, size int) (*LogrusBufferHook, *RingBuffer)
- func Prettify(i interface{}) string
- func PrettifyJson(i interface{}, indent bool) string
- func PrettifyYaml(i interface{}) string
- func Realpath(path string) string
- func String(v string) *string
- func StringValue(v *string) string
- type Consul
- type ESIndexRotate
- type ElasticHook
- type Iterator
- type LogrusBufferHook
- type RingBuffer
- type RingBufferData
- type Set
- type SimpleTimer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrESCreateIndex = fmt.Errorf("es: create elasticsearch index error") ErrConsulKeyNotExist = fmt.Errorf("consul: key not exist") )
Functions ¶
func NewLogrusBufferHook ¶ added in v1.0.6
func NewLogrusBufferHook(levels []logrus.Level, size int) (*LogrusBufferHook, *RingBuffer)
return hook: for logrus buffer: for reading data
func Prettify ¶
func Prettify(i interface{}) string
Prettify returns the string representation of a value.
func PrettifyJson ¶
Only for normal logging purpose, 4 space indent
func PrettifyYaml ¶ added in v1.0.9
func PrettifyYaml(i interface{}) string
Only for normal logging purpose, 4 space indent
func StringValue ¶
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
Types ¶
type Consul ¶
type Consul struct {
// contains filtered or unexported fields
}
func NewConsulToken ¶ added in v1.0.8
func (*Consul) GetService ¶
func (c *Consul) GetService(service string) ([]*api.ServiceEntry, error)
type ESIndexRotate ¶
type ESIndexRotate int
const ( RotateNon ESIndexRotate = iota RotateDay RotateMonth )
type ElasticHook ¶
type ElasticHook struct {
// contains filtered or unexported fields
}
func NewElasticHook ¶
func NewElasticHook(client *elastic.Client, host string, level logrus.Level, index string, rotate ESIndexRotate) (*ElasticHook, error)
func (*ElasticHook) Cancel ¶
func (hook *ElasticHook) Cancel()
func (*ElasticHook) Levels ¶
func (hook *ElasticHook) Levels() []logrus.Level
type Iterator ¶
type Iterator struct {
C <-chan interface{}
// contains filtered or unexported fields
}
Iterator defines an iterator over a Set, its C channel can be used to range over the Set's elements.
type LogrusBufferHook ¶ added in v1.0.6
type LogrusBufferHook struct {
// contains filtered or unexported fields
}
func (*LogrusBufferHook) Cancel ¶ added in v1.0.6
func (hook *LogrusBufferHook) Cancel()
func (*LogrusBufferHook) Fire ¶ added in v1.0.6
func (hook *LogrusBufferHook) Fire(entry *logrus.Entry) error
func (*LogrusBufferHook) Levels ¶ added in v1.0.6
func (hook *LogrusBufferHook) Levels() []logrus.Level
type RingBuffer ¶ added in v1.0.6
type RingBuffer struct {
// contains filtered or unexported fields
}
func NewRingBuffer ¶ added in v1.0.6
func NewRingBuffer(size int) *RingBuffer
func (*RingBuffer) Read ¶ added in v1.0.6
func (r *RingBuffer) Read() []*RingBufferData
func (*RingBuffer) Write ¶ added in v1.0.6
func (r *RingBuffer) Write(p *RingBufferData)
type RingBufferData ¶ added in v1.0.7
type Set ¶
type Set interface {
// Adds an element to the set. Returns whether
// the item was added.
Add(i interface{}) bool
// Returns the number of elements in the set.
Cardinality() int
// Removes all elements from the set, leaving
// the empty set.
Clear()
// Returns a clone of the set using the same
// implementation, duplicating all keys.
Clone() Set
// Returns whether the given items
// are all in the set.
Contains(i ...interface{}) bool
// Returns the difference between this set
// and other. The returned set will contain
// all elements of this set that are not also
// elements of other.
//
// Note that the argument to Difference
// must be of the same type as the receiver
// of the method. Otherwise, Difference will
// panic.
Difference(other Set) Set
// Determines if two sets are equal to each
// other. If they have the same cardinality
// and contain the same elements, they are
// considered equal. The order in which
// the elements were added is irrelevant.
//
// Note that the argument to Equal must be
// of the same type as the receiver of the
// method. Otherwise, Equal will panic.
Equal(other Set) bool
// Returns a new set containing only the elements
// that exist only in both sets.
//
// Note that the argument to Intersect
// must be of the same type as the receiver
// of the method. Otherwise, Intersect will
// panic.
Intersect(other Set) Set
// Iterates over elements and executes the passed func against each element.
// If passed func returns true, stop iteration at the time.
Each(func(interface{}) bool)
// Returns a channel of elements that you can
// range over.
Iter() <-chan interface{}
// Returns an Iterator object that you can
// use to range over the set.
Iterator() *Iterator
// Remove a single element from the set.
Remove(i interface{})
// Provides a convenient string representation
// of the current state of the set.
String() string
// same type as the receiver of the method.
// Otherwise, IsSuperset will panic.
Union(other Set) Set
// Pop removes and returns an arbitrary item from the set.
Pop() interface{}
// Returns the members of the set as a slice.
ToSlice() []interface{}
}
func NewSetFromSlice ¶
func NewSetFromSlice(s []interface{}) Set
type SimpleTimer ¶
type SimpleTimer struct {
// contains filtered or unexported fields
}
func NewSimpleTimer ¶
func NewSimpleTimer(duration time.Duration) *SimpleTimer
func (*SimpleTimer) Checkpoint ¶
func (t *SimpleTimer) Checkpoint() bool
if timeout, reset it automatically
Source Files
¶
Click to show internal directories.
Click to hide internal directories.