id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
133,600
k-sone/snmpgo
variables.go
Equal
func (v *Oid) Equal(o *Oid) bool { if o == nil { return false } return v.Value.Equal(o.Value) }
go
func (v *Oid) Equal(o *Oid) bool { if o == nil { return false } return v.Value.Equal(o.Value) }
[ "func", "(", "v", "*", "Oid", ")", "Equal", "(", "o", "*", "Oid", ")", "bool", "{", "if", "o", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "v", ".", "Value", ".", "Equal", "(", "o", ".", "Value", ")", "\n", "}" ]
// Returns true if this OID is same the specified OID
[ "Returns", "true", "if", "this", "OID", "is", "same", "the", "specified", "OID" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L183-L188
133,601
k-sone/snmpgo
variables.go
AppendSubIds
func (v *Oid) AppendSubIds(subs []int) (*Oid, error) { buf := bytes.NewBufferString(v.String()) for _, i := range subs { buf.WriteString(".") buf.WriteString(strconv.Itoa(i)) } return NewOid(buf.String()) }
go
func (v *Oid) AppendSubIds(subs []int) (*Oid, error) { buf := bytes.NewBufferString(v.String()) for _, i := range subs { buf.WriteString(".") buf.WriteString(strconv.Itoa(i)) } return NewOid(buf.String()) }
[ "func", "(", "v", "*", "Oid", ")", "AppendSubIds", "(", "subs", "[", "]", "int", ")", "(", "*", "Oid", ",", "error", ")", "{", "buf", ":=", "bytes", ".", "NewBufferString", "(", "v", ".", "String", "(", ")", ")", "\n", "for", "_", ",", "i", "...
// Returns Oid with additional sub-ids
[ "Returns", "Oid", "with", "additional", "sub", "-", "ids" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L191-L198
133,602
k-sone/snmpgo
variables.go
MustNewOid
func MustNewOid(s string) *Oid { if oid, err := NewOid(s); err != nil { panic(`snmpgo.MustNewOid: ` + err.Error()) } else { return oid } }
go
func MustNewOid(s string) *Oid { if oid, err := NewOid(s); err != nil { panic(`snmpgo.MustNewOid: ` + err.Error()) } else { return oid } }
[ "func", "MustNewOid", "(", "s", "string", ")", "*", "Oid", "{", "if", "oid", ",", "err", ":=", "NewOid", "(", "s", ")", ";", "err", "!=", "nil", "{", "panic", "(", "`snmpgo.MustNewOid: `", "+", "err", ".", "Error", "(", ")", ")", "\n", "}", "else...
// MustNewOid is like NewOid but panics if argument cannot be parsed
[ "MustNewOid", "is", "like", "NewOid", "but", "panics", "if", "argument", "cannot", "be", "parsed" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L253-L259
133,603
k-sone/snmpgo
variables.go
Sort
func (o Oids) Sort() Oids { c := make(Oids, len(o)) copy(c, o) sort.Sort(sortableOids{c}) return c }
go
func (o Oids) Sort() Oids { c := make(Oids, len(o)) copy(c, o) sort.Sort(sortableOids{c}) return c }
[ "func", "(", "o", "Oids", ")", "Sort", "(", ")", "Oids", "{", "c", ":=", "make", "(", "Oids", ",", "len", "(", "o", ")", ")", "\n", "copy", "(", "c", ",", "o", ")", "\n", "sort", ".", "Sort", "(", "sortableOids", "{", "c", "}", ")", "\n", ...
// Sort a Oid list
[ "Sort", "a", "Oid", "list" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L264-L269
133,604
k-sone/snmpgo
variables.go
Uniq
func (o Oids) Uniq() Oids { return o.uniq(func(a, b *Oid) bool { if b == nil { return a == nil } else { return b.Equal(a) } }) }
go
func (o Oids) Uniq() Oids { return o.uniq(func(a, b *Oid) bool { if b == nil { return a == nil } else { return b.Equal(a) } }) }
[ "func", "(", "o", "Oids", ")", "Uniq", "(", ")", "Oids", "{", "return", "o", ".", "uniq", "(", "func", "(", "a", ",", "b", "*", "Oid", ")", "bool", "{", "if", "b", "==", "nil", "{", "return", "a", "==", "nil", "\n", "}", "else", "{", "retur...
// Filter out adjacent OID list
[ "Filter", "out", "adjacent", "OID", "list" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L284-L292
133,605
k-sone/snmpgo
variables.go
UniqBase
func (o Oids) UniqBase() Oids { return o.uniq(func(a, b *Oid) bool { if b == nil { return a == nil } else { return b.Contains(a) } }) }
go
func (o Oids) UniqBase() Oids { return o.uniq(func(a, b *Oid) bool { if b == nil { return a == nil } else { return b.Contains(a) } }) }
[ "func", "(", "o", "Oids", ")", "UniqBase", "(", ")", "Oids", "{", "return", "o", ".", "uniq", "(", "func", "(", "a", ",", "b", "*", "Oid", ")", "bool", "{", "if", "b", "==", "nil", "{", "return", "a", "==", "nil", "\n", "}", "else", "{", "r...
// Filter out adjacent OID list with the same prefix
[ "Filter", "out", "adjacent", "OID", "list", "with", "the", "same", "prefix" ]
de09377ff34857b08afdc16ea8c7c2929eb1fc6e
https://github.com/k-sone/snmpgo/blob/de09377ff34857b08afdc16ea8c7c2929eb1fc6e/variables.go#L295-L303
133,606
quipo/statsd
client.go
NewStatsdClient
func NewStatsdClient(addr string, prefix string) *StatsdClient { // allow %HOST% in the prefix string prefix = strings.Replace(prefix, "%HOST%", Hostname, 1) return &StatsdClient{ addr: addr, prefix: prefix, Logger: log.New(os.Stdout, "[StatsdClient] ", log.Ldate|log.Ltime), } }
go
func NewStatsdClient(addr string, prefix string) *StatsdClient { // allow %HOST% in the prefix string prefix = strings.Replace(prefix, "%HOST%", Hostname, 1) return &StatsdClient{ addr: addr, prefix: prefix, Logger: log.New(os.Stdout, "[StatsdClient] ", log.Ldate|log.Ltime), } }
[ "func", "NewStatsdClient", "(", "addr", "string", ",", "prefix", "string", ")", "*", "StatsdClient", "{", "// allow %HOST% in the prefix string", "prefix", "=", "strings", ".", "Replace", "(", "prefix", ",", "\"", "\"", ",", "Hostname", ",", "1", ")", "\n", ...
// NewStatsdClient - Factory
[ "NewStatsdClient", "-", "Factory" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L65-L73
133,607
quipo/statsd
client.go
CreateSocket
func (c *StatsdClient) CreateSocket() error { conn, err := net.DialTimeout(string(udpSocket), c.addr, 5*time.Second) if err != nil { return err } c.conn = conn c.sockType = udpSocket return nil }
go
func (c *StatsdClient) CreateSocket() error { conn, err := net.DialTimeout(string(udpSocket), c.addr, 5*time.Second) if err != nil { return err } c.conn = conn c.sockType = udpSocket return nil }
[ "func", "(", "c", "*", "StatsdClient", ")", "CreateSocket", "(", ")", "error", "{", "conn", ",", "err", ":=", "net", ".", "DialTimeout", "(", "string", "(", "udpSocket", ")", ",", "c", ".", "addr", ",", "5", "*", "time", ".", "Second", ")", "\n", ...
// CreateSocket creates a UDP connection to a StatsD server
[ "CreateSocket", "creates", "a", "UDP", "connection", "to", "a", "StatsD", "server" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L81-L89
133,608
quipo/statsd
client.go
CreateTCPSocket
func (c *StatsdClient) CreateTCPSocket() error { conn, err := net.DialTimeout(string(tcpSocket), c.addr, 5*time.Second) if err != nil { return err } c.conn = conn c.sockType = tcpSocket return nil }
go
func (c *StatsdClient) CreateTCPSocket() error { conn, err := net.DialTimeout(string(tcpSocket), c.addr, 5*time.Second) if err != nil { return err } c.conn = conn c.sockType = tcpSocket return nil }
[ "func", "(", "c", "*", "StatsdClient", ")", "CreateTCPSocket", "(", ")", "error", "{", "conn", ",", "err", ":=", "net", ".", "DialTimeout", "(", "string", "(", "tcpSocket", ")", ",", "c", ".", "addr", ",", "5", "*", "time", ".", "Second", ")", "\n"...
// CreateTCPSocket creates a TCP connection to a StatsD server
[ "CreateTCPSocket", "creates", "a", "TCP", "connection", "to", "a", "StatsD", "server" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L92-L100
133,609
quipo/statsd
client.go
Close
func (c *StatsdClient) Close() error { if nil == c.conn { return nil } return c.conn.Close() }
go
func (c *StatsdClient) Close() error { if nil == c.conn { return nil } return c.conn.Close() }
[ "func", "(", "c", "*", "StatsdClient", ")", "Close", "(", ")", "error", "{", "if", "nil", "==", "c", ".", "conn", "{", "return", "nil", "\n", "}", "\n", "return", "c", ".", "conn", ".", "Close", "(", ")", "\n", "}" ]
// Close the UDP connection
[ "Close", "the", "UDP", "connection" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L103-L108
133,610
quipo/statsd
client.go
IncrWithSampling
func (c *StatsdClient) IncrWithSampling(stat string, count int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } if err := checkCount(count); err != nil { return err } return c.send(stat, "%d|c", ...
go
func (c *StatsdClient) IncrWithSampling(stat string, count int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } if err := checkCount(count); err != nil { return err } return c.send(stat, "%d|c", ...
[ "func", "(", "c", "*", "StatsdClient", ")", "IncrWithSampling", "(", "stat", "string", ",", "count", "int64", ",", "sampleRate", "float32", ")", "error", "{", "if", "err", ":=", "checkSampleRate", "(", "sampleRate", ")", ";", "err", "!=", "nil", "{", "re...
// IncrWithSampling - Increment a counter metric with sampling between 0 and 1
[ "IncrWithSampling", "-", "Increment", "a", "counter", "metric", "with", "sampling", "between", "0", "and", "1" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L119-L133
133,611
quipo/statsd
client.go
Decr
func (c *StatsdClient) Decr(stat string, count int64) error { return c.DecrWithSampling(stat, count, 1) }
go
func (c *StatsdClient) Decr(stat string, count int64) error { return c.DecrWithSampling(stat, count, 1) }
[ "func", "(", "c", "*", "StatsdClient", ")", "Decr", "(", "stat", "string", ",", "count", "int64", ")", "error", "{", "return", "c", ".", "DecrWithSampling", "(", "stat", ",", "count", ",", "1", ")", "\n", "}" ]
// Decr - Decrement a counter metric. Often used to note a particular event
[ "Decr", "-", "Decrement", "a", "counter", "metric", ".", "Often", "used", "to", "note", "a", "particular", "event" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L136-L138
133,612
quipo/statsd
client.go
TimingWithSampling
func (c *StatsdClient) TimingWithSampling(stat string, delta int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } return c.send(stat, "%d|ms", delta, sampleRate) }
go
func (c *StatsdClient) TimingWithSampling(stat string, delta int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } return c.send(stat, "%d|ms", delta, sampleRate) }
[ "func", "(", "c", "*", "StatsdClient", ")", "TimingWithSampling", "(", "stat", "string", ",", "delta", "int64", ",", "sampleRate", "float32", ")", "error", "{", "if", "err", ":=", "checkSampleRate", "(", "sampleRate", ")", ";", "err", "!=", "nil", "{", "...
// TimingWithSampling - Track a duration event
[ "TimingWithSampling", "-", "Track", "a", "duration", "event" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L164-L174
133,613
quipo/statsd
client.go
GaugeWithSampling
func (c *StatsdClient) GaugeWithSampling(stat string, value int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } if value < 0 { err := c.send(stat, "%d|g", 0, 1) if nil != err { return err } ...
go
func (c *StatsdClient) GaugeWithSampling(stat string, value int64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil // ignore this call } if value < 0 { err := c.send(stat, "%d|g", 0, 1) if nil != err { return err } ...
[ "func", "(", "c", "*", "StatsdClient", ")", "GaugeWithSampling", "(", "stat", "string", ",", "value", "int64", ",", "sampleRate", "float32", ")", "error", "{", "if", "err", ":=", "checkSampleRate", "(", "sampleRate", ")", ";", "err", "!=", "nil", "{", "r...
// GaugeWithSampling - Gauges are a constant data type.
[ "GaugeWithSampling", "-", "Gauges", "are", "a", "constant", "data", "type", "." ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L193-L210
133,614
quipo/statsd
client.go
FGaugeWithSampling
func (c *StatsdClient) FGaugeWithSampling(stat string, value float64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil } if value < 0 { err := c.send(stat, "%d|g", 0, 1) if nil != err { return err } } return c.sen...
go
func (c *StatsdClient) FGaugeWithSampling(stat string, value float64, sampleRate float32) error { if err := checkSampleRate(sampleRate); err != nil { return err } if !shouldFire(sampleRate) { return nil } if value < 0 { err := c.send(stat, "%d|g", 0, 1) if nil != err { return err } } return c.sen...
[ "func", "(", "c", "*", "StatsdClient", ")", "FGaugeWithSampling", "(", "stat", "string", ",", "value", "float64", ",", "sampleRate", "float32", ")", "error", "{", "if", "err", ":=", "checkSampleRate", "(", "sampleRate", ")", ";", "err", "!=", "nil", "{", ...
// FGaugeWithSampling - Gauges are a constant data type.
[ "FGaugeWithSampling", "-", "Gauges", "are", "a", "constant", "data", "type", "." ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/client.go#L227-L244
133,615
quipo/statsd
bufferedclient.go
Timing
func (sb *StatsdBuffer) Timing(stat string, delta int64) error { sb.eventChannel <- event.NewTiming(stat, delta) return nil }
go
func (sb *StatsdBuffer) Timing(stat string, delta int64) error { sb.eventChannel <- event.NewTiming(stat, delta) return nil }
[ "func", "(", "sb", "*", "StatsdBuffer", ")", "Timing", "(", "stat", "string", ",", "delta", "int64", ")", "error", "{", "sb", ".", "eventChannel", "<-", "event", ".", "NewTiming", "(", "stat", ",", "delta", ")", "\n", "return", "nil", "\n", "}" ]
// Timing - Track a duration event
[ "Timing", "-", "Track", "a", "duration", "event" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/bufferedclient.go#L71-L74
133,616
quipo/statsd
bufferedclient.go
FGauge
func (sb *StatsdBuffer) FGauge(stat string, value float64) error { sb.eventChannel <- &event.FGauge{Name: stat, Value: value} return nil }
go
func (sb *StatsdBuffer) FGauge(stat string, value float64) error { sb.eventChannel <- &event.FGauge{Name: stat, Value: value} return nil }
[ "func", "(", "sb", "*", "StatsdBuffer", ")", "FGauge", "(", "stat", "string", ",", "value", "float64", ")", "error", "{", "sb", ".", "eventChannel", "<-", "&", "event", ".", "FGauge", "{", "Name", ":", "stat", ",", "Value", ":", "value", "}", "\n", ...
// FGauge is a Gauge working with float64 values
[ "FGauge", "is", "a", "Gauge", "working", "with", "float64", "values" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/bufferedclient.go#L98-L101
133,617
quipo/statsd
bufferedclient.go
SendEvents
func (sb *StatsdBuffer) SendEvents(events map[string]event.Event) error { for _, e := range events { sb.eventChannel <- e } return nil }
go
func (sb *StatsdBuffer) SendEvents(events map[string]event.Event) error { for _, e := range events { sb.eventChannel <- e } return nil }
[ "func", "(", "sb", "*", "StatsdBuffer", ")", "SendEvents", "(", "events", "map", "[", "string", "]", "event", ".", "Event", ")", "error", "{", "for", "_", ",", "e", ":=", "range", "events", "{", "sb", ".", "eventChannel", "<-", "e", "\n", "}", "\n"...
// SendEvents - Sends stats from all the event objects.
[ "SendEvents", "-", "Sends", "stats", "from", "all", "the", "event", "objects", "." ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/bufferedclient.go#L128-L133
133,618
quipo/statsd
bufferedclient.go
initMemoisedKeyMap
func initMemoisedKeyMap() func(typ string, key string) string { m := make(map[string]map[string]string) return func(typ string, key string) string { if _, ok := m[typ]; !ok { m[typ] = make(map[string]string) } k, ok := m[typ][key] if !ok { m[typ][key] = typ + "|" + key return m[typ][key] } return...
go
func initMemoisedKeyMap() func(typ string, key string) string { m := make(map[string]map[string]string) return func(typ string, key string) string { if _, ok := m[typ]; !ok { m[typ] = make(map[string]string) } k, ok := m[typ][key] if !ok { m[typ][key] = typ + "|" + key return m[typ][key] } return...
[ "func", "initMemoisedKeyMap", "(", ")", "func", "(", "typ", "string", ",", "key", "string", ")", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ")", "\n", "return", "func", "(", "typ", "string",...
// avoid too many allocations by memoizing the "type|key" pair for an event // @see https://gobyexample.com/closures
[ "avoid", "too", "many", "allocations", "by", "memoizing", "the", "type|key", "pair", "for", "an", "event" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/bufferedclient.go#L137-L150
133,619
quipo/statsd
bufferedclient.go
Close
func (sb *StatsdBuffer) Close() (err error) { // 1. send a close event to the collector req := closeRequest{reply: make(chan error)} sb.closeChannel <- req // 2. wait for the collector to drain the queue and respond err = <-req.reply // 3. close the statsd client err2 := sb.statsd.Close() if err != nil { retu...
go
func (sb *StatsdBuffer) Close() (err error) { // 1. send a close event to the collector req := closeRequest{reply: make(chan error)} sb.closeChannel <- req // 2. wait for the collector to drain the queue and respond err = <-req.reply // 3. close the statsd client err2 := sb.statsd.Close() if err != nil { retu...
[ "func", "(", "sb", "*", "StatsdBuffer", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "// 1. send a close event to the collector", "req", ":=", "closeRequest", "{", "reply", ":", "make", "(", "chan", "error", ")", "}", "\n", "sb", ".", "closeChann...
// Close sends a close event to the collector asking to stop & flush pending stats // and closes the statsd client
[ "Close", "sends", "a", "close", "event", "to", "the", "collector", "asking", "to", "stop", "&", "flush", "pending", "stats", "and", "closes", "the", "statsd", "client" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/bufferedclient.go#L205-L217
133,620
quipo/statsd
event/precisiontiming.go
NewPrecisionTiming
func NewPrecisionTiming(k string, delta time.Duration) *PrecisionTiming { return &PrecisionTiming{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} }
go
func NewPrecisionTiming(k string, delta time.Duration) *PrecisionTiming { return &PrecisionTiming{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} }
[ "func", "NewPrecisionTiming", "(", "k", "string", ",", "delta", "time", ".", "Duration", ")", "*", "PrecisionTiming", "{", "return", "&", "PrecisionTiming", "{", "Name", ":", "k", ",", "Min", ":", "delta", ",", "Max", ":", "delta", ",", "Value", ":", "...
// NewPrecisionTiming is a factory for a Timing event, setting the Count to 1 to prevent div_by_0 errors
[ "NewPrecisionTiming", "is", "a", "factory", "for", "a", "Timing", "event", "setting", "the", "Count", "to", "1", "to", "prevent", "div_by_0", "errors" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/event/precisiontiming.go#L18-L20
133,621
quipo/statsd
event/precisiontiming.go
durationToMs
func (e PrecisionTiming) durationToMs(x time.Duration) float64 { return float64(x) / float64(time.Millisecond) }
go
func (e PrecisionTiming) durationToMs(x time.Duration) float64 { return float64(x) / float64(time.Millisecond) }
[ "func", "(", "e", "PrecisionTiming", ")", "durationToMs", "(", "x", "time", ".", "Duration", ")", "float64", "{", "return", "float64", "(", "x", ")", "/", "float64", "(", "time", ".", "Millisecond", ")", "\n", "}" ]
// durationToMs converts time.Duration into the corresponding value in milliseconds
[ "durationToMs", "converts", "time", ".", "Duration", "into", "the", "corresponding", "value", "in", "milliseconds" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/event/precisiontiming.go#L51-L53
133,622
quipo/statsd
event/timing.go
NewTiming
func NewTiming(k string, delta int64) *Timing { return &Timing{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} }
go
func NewTiming(k string, delta int64) *Timing { return &Timing{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} }
[ "func", "NewTiming", "(", "k", "string", ",", "delta", "int64", ")", "*", "Timing", "{", "return", "&", "Timing", "{", "Name", ":", "k", ",", "Min", ":", "delta", ",", "Max", ":", "delta", ",", "Value", ":", "delta", ",", "Count", ":", "1", "}", ...
// NewTiming is a factory for a Timing event, setting the Count to 1 to prevent div_by_0 errors
[ "NewTiming", "is", "a", "factory", "for", "a", "Timing", "event", "setting", "the", "Count", "to", "1", "to", "prevent", "div_by_0", "errors" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/event/timing.go#L15-L17
133,623
quipo/statsd
event/timing.go
Payload
func (e Timing) Payload() interface{} { return map[string]int64{ "min": e.Min, "max": e.Max, "val": e.Value, "cnt": e.Count, } }
go
func (e Timing) Payload() interface{} { return map[string]int64{ "min": e.Min, "max": e.Max, "val": e.Value, "cnt": e.Count, } }
[ "func", "(", "e", "Timing", ")", "Payload", "(", ")", "interface", "{", "}", "{", "return", "map", "[", "string", "]", "int64", "{", "\"", "\"", ":", "e", ".", "Min", ",", "\"", "\"", ":", "e", ".", "Max", ",", "\"", "\"", ":", "e", ".", "V...
// Payload returns the aggregated value for this event
[ "Payload", "returns", "the", "aggregated", "value", "for", "this", "event" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/event/timing.go#L33-L40
133,624
quipo/statsd
event/interface.go
_
func _() { var _ Event = (*Absolute)(nil) // assert *Absolute implements Event var _ Event = (*FAbsolute)(nil) // assert *FAbsolute implements Event var _ Event = (*Gauge)(nil) // assert *Gauge implements Event var _ Event = (*FGauge)(nil) // assert *FGauge implements Event var _ Ev...
go
func _() { var _ Event = (*Absolute)(nil) // assert *Absolute implements Event var _ Event = (*FAbsolute)(nil) // assert *FAbsolute implements Event var _ Event = (*Gauge)(nil) // assert *Gauge implements Event var _ Event = (*FGauge)(nil) // assert *FGauge implements Event var _ Ev...
[ "func", "_", "(", ")", "{", "var", "_", "Event", "=", "(", "*", "Absolute", ")", "(", "nil", ")", "// assert *Absolute implements Event", "\n", "var", "_", "Event", "=", "(", "*", "FAbsolute", ")", "(", "nil", ")", "// assert *FAbsolute implements Event", ...
// compile-time assertion to verify default events implement the Event interface
[ "compile", "-", "time", "assertion", "to", "verify", "default", "events", "implement", "the", "Event", "interface" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/event/interface.go#L30-L41
133,625
quipo/statsd
mock/mockableclient.go
CreateSocket
func (msc *MockStatsdClient) CreateSocket() error { if msc.CreateSocketFn == nil { return nil } return msc.CreateSocketFn() }
go
func (msc *MockStatsdClient) CreateSocket() error { if msc.CreateSocketFn == nil { return nil } return msc.CreateSocketFn() }
[ "func", "(", "msc", "*", "MockStatsdClient", ")", "CreateSocket", "(", ")", "error", "{", "if", "msc", ".", "CreateSocketFn", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "msc", ".", "CreateSocketFn", "(", ")", "\n", "}" ]
// Implement statsd interface
[ "Implement", "statsd", "interface" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/mock/mockableclient.go#L62-L67
133,626
quipo/statsd
noopclient.go
PrecisionTiming
func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error { return nil }
go
func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error { return nil }
[ "func", "(", "s", "NoopClient", ")", "PrecisionTiming", "(", "stat", "string", ",", "delta", "time", ".", "Duration", ")", "error", "{", "return", "nil", "\n", "}" ]
// PrecisionTiming does nothing
[ "PrecisionTiming", "does", "nothing" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/noopclient.go#L45-L47
133,627
quipo/statsd
stdoutclient.go
NewStdoutClient
func NewStdoutClient(filename string, prefix string) *StdoutClient { var err error // allow %HOST% in the prefix string prefix = strings.Replace(prefix, "%HOST%", Hostname, 1) var fh *os.File if filename == "" { fh = os.Stdout } else { fh, err = os.OpenFile(filename, os.O_WRONLY, 0644) if nil != err { fm...
go
func NewStdoutClient(filename string, prefix string) *StdoutClient { var err error // allow %HOST% in the prefix string prefix = strings.Replace(prefix, "%HOST%", Hostname, 1) var fh *os.File if filename == "" { fh = os.Stdout } else { fh, err = os.OpenFile(filename, os.O_WRONLY, 0644) if nil != err { fm...
[ "func", "NewStdoutClient", "(", "filename", "string", ",", "prefix", "string", ")", "*", "StdoutClient", "{", "var", "err", "error", "\n", "// allow %HOST% in the prefix string", "prefix", "=", "strings", ".", "Replace", "(", "prefix", ",", "\"", "\"", ",", "H...
// NewStdoutClient - Factory
[ "NewStdoutClient", "-", "Factory" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/stdoutclient.go#L21-L39
133,628
quipo/statsd
stdoutclient.go
CreateSocket
func (s *StdoutClient) CreateSocket() error { if s.FD == nil { s.FD = os.Stdout } return nil }
go
func (s *StdoutClient) CreateSocket() error { if s.FD == nil { s.FD = os.Stdout } return nil }
[ "func", "(", "s", "*", "StdoutClient", ")", "CreateSocket", "(", ")", "error", "{", "if", "s", ".", "FD", "==", "nil", "{", "s", ".", "FD", "=", "os", ".", "Stdout", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CreateSocket does nothing
[ "CreateSocket", "does", "nothing" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/stdoutclient.go#L42-L47
133,629
quipo/statsd
stdoutclient.go
CreateTCPSocket
func (s *StdoutClient) CreateTCPSocket() error { if s.FD == nil { s.FD = os.Stdout } return nil }
go
func (s *StdoutClient) CreateTCPSocket() error { if s.FD == nil { s.FD = os.Stdout } return nil }
[ "func", "(", "s", "*", "StdoutClient", ")", "CreateTCPSocket", "(", ")", "error", "{", "if", "s", ".", "FD", "==", "nil", "{", "s", ".", "FD", "=", "os", ".", "Stdout", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CreateTCPSocket does nothing
[ "CreateTCPSocket", "does", "nothing" ]
3d6a5565f3141ac42f8353d97b2c016da2752006
https://github.com/quipo/statsd/blob/3d6a5565f3141ac42f8353d97b2c016da2752006/stdoutclient.go#L50-L55
133,630
rs/xlog
util.go
writeValue
func writeValue(w io.Writer, v interface{}) (err error) { switch v := v.(type) { case nil: _, err = w.Write([]byte("null")) case string: if strings.IndexFunc(v, needsQuotedValueRune) != -1 { var b []byte b, err = json.Marshal(v) if err == nil { w.Write(b) } } else { _, err = w.Write([]byte(v...
go
func writeValue(w io.Writer, v interface{}) (err error) { switch v := v.(type) { case nil: _, err = w.Write([]byte("null")) case string: if strings.IndexFunc(v, needsQuotedValueRune) != -1 { var b []byte b, err = json.Marshal(v) if err == nil { w.Write(b) } } else { _, err = w.Write([]byte(v...
[ "func", "writeValue", "(", "w", "io", ".", "Writer", ",", "v", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "switch", "v", ":=", "v", ".", "(", "type", ")", "{", "case", "nil", ":", "_", ",", "err", "=", "w", ".", "Write", "(", ...
// writeValue writes a value on the writer in a logfmt compatible way
[ "writeValue", "writes", "a", "value", "on", "the", "writer", "in", "a", "logfmt", "compatible", "way" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/util.go#L31-L53
133,631
rs/xlog
handler_pre17.go
IDFromContext
func IDFromContext(ctx context.Context) (xid.ID, bool) { id, ok := ctx.Value(idKey).(xid.ID) return id, ok }
go
func IDFromContext(ctx context.Context) (xid.ID, bool) { id, ok := ctx.Value(idKey).(xid.ID) return id, ok }
[ "func", "IDFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "xid", ".", "ID", ",", "bool", ")", "{", "id", ",", "ok", ":=", "ctx", ".", "Value", "(", "idKey", ")", ".", "(", "xid", ".", "ID", ")", "\n", "return", "id", ",", "ok", ...
// IDFromContext returns the unique id associated to the request if any.
[ "IDFromContext", "returns", "the", "unique", "id", "associated", "to", "the", "request", "if", "any", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler_pre17.go#L22-L25
133,632
rs/xlog
handler_pre17.go
FromContext
func FromContext(ctx context.Context) Logger { if ctx == nil { return NopLogger } l, ok := ctx.Value(logKey).(Logger) if !ok { return NopLogger } return l }
go
func FromContext(ctx context.Context) Logger { if ctx == nil { return NopLogger } l, ok := ctx.Value(logKey).(Logger) if !ok { return NopLogger } return l }
[ "func", "FromContext", "(", "ctx", "context", ".", "Context", ")", "Logger", "{", "if", "ctx", "==", "nil", "{", "return", "NopLogger", "\n", "}", "\n", "l", ",", "ok", ":=", "ctx", ".", "Value", "(", "logKey", ")", ".", "(", "Logger", ")", "\n", ...
// FromContext gets the logger out of the context. // If not logger is stored in the context, a NopLogger is returned.
[ "FromContext", "gets", "the", "logger", "out", "of", "the", "context", ".", "If", "not", "logger", "is", "stored", "in", "the", "context", "a", "NopLogger", "is", "returned", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler_pre17.go#L29-L38
133,633
rs/xlog
handler_pre17.go
NewContext
func NewContext(ctx context.Context, l Logger) context.Context { return context.WithValue(ctx, logKey, l) }
go
func NewContext(ctx context.Context, l Logger) context.Context { return context.WithValue(ctx, logKey, l) }
[ "func", "NewContext", "(", "ctx", "context", ".", "Context", ",", "l", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "logKey", ",", "l", ")", "\n", "}" ]
// NewContext returns a copy of the parent context and associates it with the provided logger.
[ "NewContext", "returns", "a", "copy", "of", "the", "parent", "context", "and", "associates", "it", "with", "the", "provided", "logger", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler_pre17.go#L41-L43
133,634
rs/xlog
handler_pre17.go
RequestHandler
func RequestHandler(name string) func(next xhandler.HandlerC) xhandler.HandlerC { return func(next xhandler.HandlerC) xhandler.HandlerC { return xhandler.HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { FromContext(ctx).SetField(name, r.Method+" "+r.URL.String()) next.ServeHTTPC...
go
func RequestHandler(name string) func(next xhandler.HandlerC) xhandler.HandlerC { return func(next xhandler.HandlerC) xhandler.HandlerC { return xhandler.HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { FromContext(ctx).SetField(name, r.Method+" "+r.URL.String()) next.ServeHTTPC...
[ "func", "RequestHandler", "(", "name", "string", ")", "func", "(", "next", "xhandler", ".", "HandlerC", ")", "xhandler", ".", "HandlerC", "{", "return", "func", "(", "next", "xhandler", ".", "HandlerC", ")", "xhandler", ".", "HandlerC", "{", "return", "xha...
// RequestHandler returns a handler setting the request's method and URL as a field // to the current context's logger using the passed name as field name.
[ "RequestHandler", "returns", "a", "handler", "setting", "the", "request", "s", "method", "and", "URL", "as", "a", "field", "to", "the", "current", "context", "s", "logger", "using", "the", "passed", "name", "as", "field", "name", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler_pre17.go#L88-L95
133,635
rs/xlog
xlog.go
New
func New(c Config) Logger { var l *logger if c.DisablePooling { l = &logger{} } else { l = loggerPool.Get().(*logger) } l.level = c.Level l.output = c.Output if l.output == nil { l.output = NewOutputChannel(NewConsoleOutput()) } for k, v := range c.Fields { l.SetField(k, v) } l.disablePooling = c.Dis...
go
func New(c Config) Logger { var l *logger if c.DisablePooling { l = &logger{} } else { l = loggerPool.Get().(*logger) } l.level = c.Level l.output = c.Output if l.output == nil { l.output = NewOutputChannel(NewConsoleOutput()) } for k, v := range c.Fields { l.SetField(k, v) } l.disablePooling = c.Dis...
[ "func", "New", "(", "c", "Config", ")", "Logger", "{", "var", "l", "*", "logger", "\n", "if", "c", ".", "DisablePooling", "{", "l", "=", "&", "logger", "{", "}", "\n", "}", "else", "{", "l", "=", "loggerPool", ".", "Get", "(", ")", ".", "(", ...
// New manually creates a logger. // // This function should only be used out of a request. Use FromContext in request.
[ "New", "manually", "creates", "a", "logger", ".", "This", "function", "should", "only", "be", "used", "out", "of", "a", "request", ".", "Use", "FromContext", "in", "request", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L139-L156
133,636
rs/xlog
xlog.go
Copy
func Copy(l Logger) Logger { if l, ok := l.(LoggerCopier); ok { return l.Copy() } return NopLogger }
go
func Copy(l Logger) Logger { if l, ok := l.(LoggerCopier); ok { return l.Copy() } return NopLogger }
[ "func", "Copy", "(", "l", "Logger", ")", "Logger", "{", "if", "l", ",", "ok", ":=", "l", ".", "(", "LoggerCopier", ")", ";", "ok", "{", "return", "l", ".", "Copy", "(", ")", "\n", "}", "\n", "return", "NopLogger", "\n", "}" ]
// Copy returns a copy of the passed logger if the logger implements // LoggerCopier or the NopLogger otherwise.
[ "Copy", "returns", "a", "copy", "of", "the", "passed", "logger", "if", "the", "logger", "implements", "LoggerCopier", "or", "the", "NopLogger", "otherwise", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L160-L165
133,637
rs/xlog
xlog.go
Copy
func (l *logger) Copy() Logger { l2 := &logger{ level: l.level, output: l.output, fields: map[string]interface{}{}, disablePooling: l.disablePooling, } for k, v := range l.fields { l2.fields[k] = v } return l2 }
go
func (l *logger) Copy() Logger { l2 := &logger{ level: l.level, output: l.output, fields: map[string]interface{}{}, disablePooling: l.disablePooling, } for k, v := range l.fields { l2.fields[k] = v } return l2 }
[ "func", "(", "l", "*", "logger", ")", "Copy", "(", ")", "Logger", "{", "l2", ":=", "&", "logger", "{", "level", ":", "l", ".", "level", ",", "output", ":", "l", ".", "output", ",", "fields", ":", "map", "[", "string", "]", "interface", "{", "}"...
// Copy returns a copy of the logger
[ "Copy", "returns", "a", "copy", "of", "the", "logger" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L168-L179
133,638
rs/xlog
xlog.go
close
func (l *logger) close() { if !l.disablePooling { l.level = 0 l.output = nil l.fields = nil loggerPool.Put(l) } }
go
func (l *logger) close() { if !l.disablePooling { l.level = 0 l.output = nil l.fields = nil loggerPool.Put(l) } }
[ "func", "(", "l", "*", "logger", ")", "close", "(", ")", "{", "if", "!", "l", ".", "disablePooling", "{", "l", ".", "level", "=", "0", "\n", "l", ".", "output", "=", "nil", "\n", "l", ".", "fields", "=", "nil", "\n", "loggerPool", ".", "Put", ...
// close returns the logger to the pool for reuse
[ "close", "returns", "the", "logger", "to", "the", "pool", "for", "reuse" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L182-L189
133,639
rs/xlog
xlog.go
SetField
func (l *logger) SetField(name string, value interface{}) { if l.fields == nil { l.fields = map[string]interface{}{} } l.fields[name] = value }
go
func (l *logger) SetField(name string, value interface{}) { if l.fields == nil { l.fields = map[string]interface{}{} } l.fields[name] = value }
[ "func", "(", "l", "*", "logger", ")", "SetField", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "l", ".", "fields", "==", "nil", "{", "l", ".", "fields", "=", "map", "[", "string", "]", "interface", "{", "}", "{", ...
// SetField implements Logger interface
[ "SetField", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L230-L235
133,640
rs/xlog
xlog.go
OutputF
func (l *logger) OutputF(level Level, calldepth int, msg string, fields map[string]interface{}) { l.send(level, calldepth+1, msg, fields) }
go
func (l *logger) OutputF(level Level, calldepth int, msg string, fields map[string]interface{}) { l.send(level, calldepth+1, msg, fields) }
[ "func", "(", "l", "*", "logger", ")", "OutputF", "(", "level", "Level", ",", "calldepth", "int", ",", "msg", "string", ",", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "l", ".", "send", "(", "level", ",", "calldepth", "+",...
// Output implements Logger interface
[ "Output", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L243-L245
133,641
rs/xlog
xlog.go
Debug
func (l *logger) Debug(v ...interface{}) { f := extractFields(&v) l.send(LevelDebug, 2, fmt.Sprint(v...), f) }
go
func (l *logger) Debug(v ...interface{}) { f := extractFields(&v) l.send(LevelDebug, 2, fmt.Sprint(v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Debug", "(", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelDebug", ",", "2", ",", "fmt", ".", "Sprint", "(", "v", "...", ...
// Debug implements Logger interface
[ "Debug", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L248-L251
133,642
rs/xlog
xlog.go
Debugf
func (l *logger) Debugf(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelDebug, 2, fmt.Sprintf(format, v...), f) }
go
func (l *logger) Debugf(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelDebug, 2, fmt.Sprintf(format, v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Debugf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelDebug", ",", "2", ",", "fmt", ".", "Sp...
// Debugf implements Logger interface
[ "Debugf", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L254-L257
133,643
rs/xlog
xlog.go
Info
func (l *logger) Info(v ...interface{}) { f := extractFields(&v) l.send(LevelInfo, 2, fmt.Sprint(v...), f) }
go
func (l *logger) Info(v ...interface{}) { f := extractFields(&v) l.send(LevelInfo, 2, fmt.Sprint(v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Info", "(", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelInfo", ",", "2", ",", "fmt", ".", "Sprint", "(", "v", "...", ")...
// Info implements Logger interface
[ "Info", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L260-L263
133,644
rs/xlog
xlog.go
Infof
func (l *logger) Infof(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelInfo, 2, fmt.Sprintf(format, v...), f) }
go
func (l *logger) Infof(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelInfo, 2, fmt.Sprintf(format, v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Infof", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelInfo", ",", "2", ",", "fmt", ".", "Spri...
// Infof implements Logger interface
[ "Infof", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L266-L269
133,645
rs/xlog
xlog.go
Warn
func (l *logger) Warn(v ...interface{}) { f := extractFields(&v) l.send(LevelWarn, 2, fmt.Sprint(v...), f) }
go
func (l *logger) Warn(v ...interface{}) { f := extractFields(&v) l.send(LevelWarn, 2, fmt.Sprint(v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Warn", "(", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelWarn", ",", "2", ",", "fmt", ".", "Sprint", "(", "v", "...", ")...
// Warn implements Logger interface
[ "Warn", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L272-L275
133,646
rs/xlog
xlog.go
Warnf
func (l *logger) Warnf(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelWarn, 2, fmt.Sprintf(format, v...), f) }
go
func (l *logger) Warnf(format string, v ...interface{}) { f := extractFields(&v) l.send(LevelWarn, 2, fmt.Sprintf(format, v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Warnf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelWarn", ",", "2", ",", "fmt", ".", "Spri...
// Warnf implements Logger interface
[ "Warnf", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L278-L281
133,647
rs/xlog
xlog.go
Error
func (l *logger) Error(v ...interface{}) { f := extractFields(&v) l.send(LevelError, 2, fmt.Sprint(v...), f) }
go
func (l *logger) Error(v ...interface{}) { f := extractFields(&v) l.send(LevelError, 2, fmt.Sprint(v...), f) }
[ "func", "(", "l", "*", "logger", ")", "Error", "(", "v", "...", "interface", "{", "}", ")", "{", "f", ":=", "extractFields", "(", "&", "v", ")", "\n", "l", ".", "send", "(", "LevelError", ",", "2", ",", "fmt", ".", "Sprint", "(", "v", "...", ...
// Error implements Logger interface
[ "Error", "implements", "Logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L284-L287
133,648
rs/xlog
xlog.go
Write
func (l *logger) Write(p []byte) (int, error) { msg := strings.TrimRight(string(p), "\n") l.send(LevelInfo, 4, msg, nil) if o, ok := l.output.(*OutputChannel); ok { o.Flush() } return len(p), nil }
go
func (l *logger) Write(p []byte) (int, error) { msg := strings.TrimRight(string(p), "\n") l.send(LevelInfo, 4, msg, nil) if o, ok := l.output.(*OutputChannel); ok { o.Flush() } return len(p), nil }
[ "func", "(", "l", "*", "logger", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "msg", ":=", "strings", ".", "TrimRight", "(", "string", "(", "p", ")", ",", "\"", "\\n", "\"", ")", "\n", "l", ".", "send", ...
// Write implements io.Writer interface
[ "Write", "implements", "io", ".", "Writer", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L336-L343
133,649
rs/xlog
xlog.go
Output
func (l *logger) Output(calldepth int, s string) error { l.send(LevelInfo, 2, s, nil) return nil }
go
func (l *logger) Output(calldepth int, s string) error { l.send(LevelInfo, 2, s, nil) return nil }
[ "func", "(", "l", "*", "logger", ")", "Output", "(", "calldepth", "int", ",", "s", "string", ")", "error", "{", "l", ".", "send", "(", "LevelInfo", ",", "2", ",", "s", ",", "nil", ")", "\n", "return", "nil", "\n", "}" ]
// Output implements common logger interface
[ "Output", "implements", "common", "logger", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/xlog.go#L346-L349
133,650
rs/xlog
output_syslog.go
NewSyslogOutput
func NewSyslogOutput(network, address, tag string) Output { return NewSyslogOutputFacility(network, address, tag, syslog.LOG_USER) }
go
func NewSyslogOutput(network, address, tag string) Output { return NewSyslogOutputFacility(network, address, tag, syslog.LOG_USER) }
[ "func", "NewSyslogOutput", "(", "network", ",", "address", ",", "tag", "string", ")", "Output", "{", "return", "NewSyslogOutputFacility", "(", "network", ",", "address", ",", "tag", ",", "syslog", ".", "LOG_USER", ")", "\n", "}" ]
// NewSyslogOutput returns JSONOutputs in a LevelOutput with writers set to syslog // with the proper priority added to a LOG_USER facility. // If network and address are empty, Dial will connect to the local syslog server.
[ "NewSyslogOutput", "returns", "JSONOutputs", "in", "a", "LevelOutput", "with", "writers", "set", "to", "syslog", "with", "the", "proper", "priority", "added", "to", "a", "LOG_USER", "facility", ".", "If", "network", "and", "address", "are", "empty", "Dial", "w...
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output_syslog.go#L13-L15
133,651
rs/xlog
output_syslog.go
NewSyslogOutputFacility
func NewSyslogOutputFacility(network, address, tag string, facility syslog.Priority) Output { o := LevelOutput{ Debug: NewJSONOutput(NewSyslogWriter(network, address, facility|syslog.LOG_DEBUG, tag)), Info: NewJSONOutput(NewSyslogWriter(network, address, facility|syslog.LOG_INFO, tag)), Warn: NewJSONOutput(New...
go
func NewSyslogOutputFacility(network, address, tag string, facility syslog.Priority) Output { o := LevelOutput{ Debug: NewJSONOutput(NewSyslogWriter(network, address, facility|syslog.LOG_DEBUG, tag)), Info: NewJSONOutput(NewSyslogWriter(network, address, facility|syslog.LOG_INFO, tag)), Warn: NewJSONOutput(New...
[ "func", "NewSyslogOutputFacility", "(", "network", ",", "address", ",", "tag", "string", ",", "facility", "syslog", ".", "Priority", ")", "Output", "{", "o", ":=", "LevelOutput", "{", "Debug", ":", "NewJSONOutput", "(", "NewSyslogWriter", "(", "network", ",", ...
// NewSyslogOutputFacility returns JSONOutputs in a LevelOutput with writers set to syslog // with the proper priority added to the passed facility. // If network and address are empty, Dial will connect to the local syslog server.
[ "NewSyslogOutputFacility", "returns", "JSONOutputs", "in", "a", "LevelOutput", "with", "writers", "set", "to", "syslog", "with", "the", "proper", "priority", "added", "to", "the", "passed", "facility", ".", "If", "network", "and", "address", "are", "empty", "Dia...
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output_syslog.go#L20-L28
133,652
rs/xlog
output_syslog.go
NewSyslogWriter
func NewSyslogWriter(network, address string, prio syslog.Priority, tag string) io.Writer { s, err := syslog.Dial(network, address, prio, tag) if err != nil { m := "syslog dial error: " + err.Error() critialLogger.Print(m) panic(m) } return s }
go
func NewSyslogWriter(network, address string, prio syslog.Priority, tag string) io.Writer { s, err := syslog.Dial(network, address, prio, tag) if err != nil { m := "syslog dial error: " + err.Error() critialLogger.Print(m) panic(m) } return s }
[ "func", "NewSyslogWriter", "(", "network", ",", "address", "string", ",", "prio", "syslog", ".", "Priority", ",", "tag", "string", ")", "io", ".", "Writer", "{", "s", ",", "err", ":=", "syslog", ".", "Dial", "(", "network", ",", "address", ",", "prio",...
// NewSyslogWriter returns a writer ready to be used with output modules. // If network and address are empty, Dial will connect to the local syslog server.
[ "NewSyslogWriter", "returns", "a", "writer", "ready", "to", "be", "used", "with", "output", "modules", ".", "If", "network", "and", "address", "are", "empty", "Dial", "will", "connect", "to", "the", "local", "syslog", "server", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output_syslog.go#L32-L40
133,653
rs/xlog
output.go
NewOutputChannelBuffer
func NewOutputChannelBuffer(o Output, bufSize int) *OutputChannel { oc := &OutputChannel{ input: make(chan map[string]interface{}, bufSize), output: o, stop: make(chan struct{}), } go func() { for { select { case msg := <-oc.input: if err := o.Write(msg); err != nil { critialLogger.Print("...
go
func NewOutputChannelBuffer(o Output, bufSize int) *OutputChannel { oc := &OutputChannel{ input: make(chan map[string]interface{}, bufSize), output: o, stop: make(chan struct{}), } go func() { for { select { case msg := <-oc.input: if err := o.Write(msg); err != nil { critialLogger.Print("...
[ "func", "NewOutputChannelBuffer", "(", "o", "Output", ",", "bufSize", "int", ")", "*", "OutputChannel", "{", "oc", ":=", "&", "OutputChannel", "{", "input", ":", "make", "(", "chan", "map", "[", "string", "]", "interface", "{", "}", ",", "bufSize", ")", ...
// NewOutputChannelBuffer creates a consumer buffered channel for the given output // with a customizable buffer size.
[ "NewOutputChannelBuffer", "creates", "a", "consumer", "buffered", "channel", "for", "the", "given", "output", "with", "a", "customizable", "buffer", "size", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L51-L73
133,654
rs/xlog
output.go
Write
func (oc *OutputChannel) Write(fields map[string]interface{}) (err error) { select { case oc.input <- fields: // Sent with success default: // Channel is full, message dropped err = ErrBufferFull } return err }
go
func (oc *OutputChannel) Write(fields map[string]interface{}) (err error) { select { case oc.input <- fields: // Sent with success default: // Channel is full, message dropped err = ErrBufferFull } return err }
[ "func", "(", "oc", "*", "OutputChannel", ")", "Write", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "select", "{", "case", "oc", ".", "input", "<-", "fields", ":", "// Sent with success", "default...
// Write implements the Output interface
[ "Write", "implements", "the", "Output", "interface" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L76-L85
133,655
rs/xlog
output.go
Flush
func (oc *OutputChannel) Flush() { for { select { case msg := <-oc.input: if err := oc.output.Write(msg); err != nil { critialLogger.Print("cannot write log message: ", err.Error()) } default: return } } }
go
func (oc *OutputChannel) Flush() { for { select { case msg := <-oc.input: if err := oc.output.Write(msg); err != nil { critialLogger.Print("cannot write log message: ", err.Error()) } default: return } } }
[ "func", "(", "oc", "*", "OutputChannel", ")", "Flush", "(", ")", "{", "for", "{", "select", "{", "case", "msg", ":=", "<-", "oc", ".", "input", ":", "if", "err", ":=", "oc", ".", "output", ".", "Write", "(", "msg", ")", ";", "err", "!=", "nil",...
// Flush flushes all the buffered message to the output
[ "Flush", "flushes", "all", "the", "buffered", "message", "to", "the", "output" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L88-L99
133,656
rs/xlog
output.go
Close
func (oc *OutputChannel) Close() { if oc.stop == nil { return } oc.stop <- struct{}{} <-oc.stop oc.stop = nil oc.Flush() }
go
func (oc *OutputChannel) Close() { if oc.stop == nil { return } oc.stop <- struct{}{} <-oc.stop oc.stop = nil oc.Flush() }
[ "func", "(", "oc", "*", "OutputChannel", ")", "Close", "(", ")", "{", "if", "oc", ".", "stop", "==", "nil", "{", "return", "\n", "}", "\n", "oc", ".", "stop", "<-", "struct", "{", "}", "{", "}", "\n", "<-", "oc", ".", "stop", "\n", "oc", ".",...
// Close closes the output channel and release the consumer's go routine.
[ "Close", "closes", "the", "output", "channel", "and", "release", "the", "consumer", "s", "go", "routine", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L102-L110
133,657
rs/xlog
output.go
NewConsoleOutputW
func NewConsoleOutputW(w io.Writer, noTerm Output) Output { if isTerminal(w) { return consoleOutput{w: w} } return noTerm }
go
func NewConsoleOutputW(w io.Writer, noTerm Output) Output { if isTerminal(w) { return consoleOutput{w: w} } return noTerm }
[ "func", "NewConsoleOutputW", "(", "w", "io", ".", "Writer", ",", "noTerm", "Output", ")", "Output", "{", "if", "isTerminal", "(", "w", ")", "{", "return", "consoleOutput", "{", "w", ":", "w", "}", "\n", "}", "\n", "return", "noTerm", "\n", "}" ]
// NewConsoleOutputW returns a Output printing message in a colored human readable form with // the provided writer. If the writer is not on a terminal, the noTerm output is returned.
[ "NewConsoleOutputW", "returns", "a", "Output", "printing", "message", "in", "a", "colored", "human", "readable", "form", "with", "the", "provided", "writer", ".", "If", "the", "writer", "is", "not", "on", "a", "terminal", "the", "noTerm", "output", "is", "re...
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L216-L221
133,658
rs/xlog
output.go
NewJSONOutput
func NewJSONOutput(w io.Writer) Output { enc := json.NewEncoder(w) return OutputFunc(func(fields map[string]interface{}) error { return enc.Encode(fields) }) }
go
func NewJSONOutput(w io.Writer) Output { enc := json.NewEncoder(w) return OutputFunc(func(fields map[string]interface{}) error { return enc.Encode(fields) }) }
[ "func", "NewJSONOutput", "(", "w", "io", ".", "Writer", ")", "Output", "{", "enc", ":=", "json", ".", "NewEncoder", "(", "w", ")", "\n", "return", "OutputFunc", "(", "func", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "error...
// NewJSONOutput returns a new JSON output with the given writer.
[ "NewJSONOutput", "returns", "a", "new", "JSON", "output", "with", "the", "given", "writer", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L320-L325
133,659
rs/xlog
output.go
NewLogstashOutput
func NewLogstashOutput(w io.Writer) Output { return OutputFunc(func(fields map[string]interface{}) error { lsf := map[string]interface{}{ "@version": 1, } for k, v := range fields { switch k { case KeyTime: k = "@timestamp" case KeyLevel: if s, ok := v.(string); ok { v = strings.ToUpper(...
go
func NewLogstashOutput(w io.Writer) Output { return OutputFunc(func(fields map[string]interface{}) error { lsf := map[string]interface{}{ "@version": 1, } for k, v := range fields { switch k { case KeyTime: k = "@timestamp" case KeyLevel: if s, ok := v.(string); ok { v = strings.ToUpper(...
[ "func", "NewLogstashOutput", "(", "w", "io", ".", "Writer", ")", "Output", "{", "return", "OutputFunc", "(", "func", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "lsf", ":=", "map", "[", "string", "]", "interface"...
// NewLogstashOutput returns an output to generate logstash friendly JSON format.
[ "NewLogstashOutput", "returns", "an", "output", "to", "generate", "logstash", "friendly", "JSON", "format", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L328-L355
133,660
rs/xlog
output.go
NewTrimOutput
func NewTrimOutput(maxLen int, o Output) Output { return OutputFunc(func(fields map[string]interface{}) error { for k, v := range fields { if s, ok := v.(string); ok && len(s) > maxLen { fields[k] = s[:maxLen] } } return o.Write(fields) }) }
go
func NewTrimOutput(maxLen int, o Output) Output { return OutputFunc(func(fields map[string]interface{}) error { for k, v := range fields { if s, ok := v.(string); ok && len(s) > maxLen { fields[k] = s[:maxLen] } } return o.Write(fields) }) }
[ "func", "NewTrimOutput", "(", "maxLen", "int", ",", "o", "Output", ")", "Output", "{", "return", "OutputFunc", "(", "func", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "for", "k", ",", "v", ":=", "range", "fiel...
// NewTrimOutput trims any field of type string with a value length greater than maxLen // to maxLen.
[ "NewTrimOutput", "trims", "any", "field", "of", "type", "string", "with", "a", "value", "length", "greater", "than", "maxLen", "to", "maxLen", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L369-L378
133,661
rs/xlog
output.go
NewTrimFieldsOutput
func NewTrimFieldsOutput(trimFields []string, maxLen int, o Output) Output { return OutputFunc(func(fields map[string]interface{}) error { for _, f := range trimFields { if s, ok := fields[f].(string); ok && len(s) > maxLen { fields[f] = s[:maxLen] } } return o.Write(fields) }) }
go
func NewTrimFieldsOutput(trimFields []string, maxLen int, o Output) Output { return OutputFunc(func(fields map[string]interface{}) error { for _, f := range trimFields { if s, ok := fields[f].(string); ok && len(s) > maxLen { fields[f] = s[:maxLen] } } return o.Write(fields) }) }
[ "func", "NewTrimFieldsOutput", "(", "trimFields", "[", "]", "string", ",", "maxLen", "int", ",", "o", "Output", ")", "Output", "{", "return", "OutputFunc", "(", "func", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", ...
// NewTrimFieldsOutput trims listed field fields of type string with a value length greater than maxLen // to maxLen.
[ "NewTrimFieldsOutput", "trims", "listed", "field", "fields", "of", "type", "string", "with", "a", "value", "length", "greater", "than", "maxLen", "to", "maxLen", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/output.go#L382-L391
133,662
rs/xlog
handler.go
IDFromRequest
func IDFromRequest(r *http.Request) (xid.ID, bool) { if r == nil { return xid.ID{}, false } return IDFromContext(r.Context()) }
go
func IDFromRequest(r *http.Request) (xid.ID, bool) { if r == nil { return xid.ID{}, false } return IDFromContext(r.Context()) }
[ "func", "IDFromRequest", "(", "r", "*", "http", ".", "Request", ")", "(", "xid", ".", "ID", ",", "bool", ")", "{", "if", "r", "==", "nil", "{", "return", "xid", ".", "ID", "{", "}", ",", "false", "\n", "}", "\n", "return", "IDFromContext", "(", ...
// IDFromRequest returns the unique id accociated to the request if any.
[ "IDFromRequest", "returns", "the", "unique", "id", "accociated", "to", "the", "request", "if", "any", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler.go#L27-L32
133,663
rs/xlog
handler.go
URLHandler
func URLHandler(name string) func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { l := FromContext(r.Context()) l.SetField(name, r.URL.String()) next.ServeHTTP(w, r) }) } }
go
func URLHandler(name string) func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { l := FromContext(r.Context()) l.SetField(name, r.URL.String()) next.ServeHTTP(w, r) }) } }
[ "func", "URLHandler", "(", "name", "string", ")", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFun...
// URLHandler returns a handler setting the request's URL as a field // to the current context's logger using the passed name as field name.
[ "URLHandler", "returns", "a", "handler", "setting", "the", "request", "s", "URL", "as", "a", "field", "to", "the", "current", "context", "s", "logger", "using", "the", "passed", "name", "as", "field", "name", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/handler.go#L85-L93
133,664
rs/xlog
levels.go
LevelFromString
func LevelFromString(t string) (Level, error) { l := Level(0) err := (&l).UnmarshalText([]byte(t)) return l, err }
go
func LevelFromString(t string) (Level, error) { l := Level(0) err := (&l).UnmarshalText([]byte(t)) return l, err }
[ "func", "LevelFromString", "(", "t", "string", ")", "(", "Level", ",", "error", ")", "{", "l", ":=", "Level", "(", "0", ")", "\n", "err", ":=", "(", "&", "l", ")", ".", "UnmarshalText", "(", "[", "]", "byte", "(", "t", ")", ")", "\n", "return",...
// LevelFromString returns the level based on its string representation
[ "LevelFromString", "returns", "the", "level", "based", "on", "its", "string", "representation" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/levels.go#L37-L41
133,665
rs/xlog
levels.go
UnmarshalText
func (l *Level) UnmarshalText(text []byte) (err error) { if bytes.Equal(text, levelBytesDebug) { *l = LevelDebug } else if bytes.Equal(text, levelBytesInfo) { *l = LevelInfo } else if bytes.Equal(text, levelBytesWarn) { *l = LevelWarn } else if bytes.Equal(text, levelBytesError) { *l = LevelError } else if...
go
func (l *Level) UnmarshalText(text []byte) (err error) { if bytes.Equal(text, levelBytesDebug) { *l = LevelDebug } else if bytes.Equal(text, levelBytesInfo) { *l = LevelInfo } else if bytes.Equal(text, levelBytesWarn) { *l = LevelWarn } else if bytes.Equal(text, levelBytesError) { *l = LevelError } else if...
[ "func", "(", "l", "*", "Level", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "if", "bytes", ".", "Equal", "(", "text", ",", "levelBytesDebug", ")", "{", "*", "l", "=", "LevelDebug", "\n", "}", "else", "...
// UnmarshalText lets Level implements the TextUnmarshaler interface used by encoding packages
[ "UnmarshalText", "lets", "Level", "implements", "the", "TextUnmarshaler", "interface", "used", "by", "encoding", "packages" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/levels.go#L44-L59
133,666
rs/xlog
levels.go
String
func (l Level) String() string { var t string switch l { case LevelDebug: t = levelDebug case LevelInfo: t = levelInfo case LevelWarn: t = levelWarn case LevelError: t = levelError case LevelFatal: t = levelFatal default: t = strconv.FormatInt(int64(l), 10) } return t }
go
func (l Level) String() string { var t string switch l { case LevelDebug: t = levelDebug case LevelInfo: t = levelInfo case LevelWarn: t = levelWarn case LevelError: t = levelError case LevelFatal: t = levelFatal default: t = strconv.FormatInt(int64(l), 10) } return t }
[ "func", "(", "l", "Level", ")", "String", "(", ")", "string", "{", "var", "t", "string", "\n", "switch", "l", "{", "case", "LevelDebug", ":", "t", "=", "levelDebug", "\n", "case", "LevelInfo", ":", "t", "=", "levelInfo", "\n", "case", "LevelWarn", ":...
// String returns the string representation of the level.
[ "String", "returns", "the", "string", "representation", "of", "the", "level", "." ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/levels.go#L62-L79
133,667
rs/xlog
levels.go
MarshalText
func (l Level) MarshalText() ([]byte, error) { var t []byte switch l { case LevelDebug: t = levelBytesDebug case LevelInfo: t = levelBytesInfo case LevelWarn: t = levelBytesWarn case LevelError: t = levelBytesError case LevelFatal: t = levelBytesFatal default: t = []byte(strconv.FormatInt(int64(l), ...
go
func (l Level) MarshalText() ([]byte, error) { var t []byte switch l { case LevelDebug: t = levelBytesDebug case LevelInfo: t = levelBytesInfo case LevelWarn: t = levelBytesWarn case LevelError: t = levelBytesError case LevelFatal: t = levelBytesFatal default: t = []byte(strconv.FormatInt(int64(l), ...
[ "func", "(", "l", "Level", ")", "MarshalText", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "t", "[", "]", "byte", "\n", "switch", "l", "{", "case", "LevelDebug", ":", "t", "=", "levelBytesDebug", "\n", "case", "LevelInfo", ":", ...
// MarshalText lets Level implements the TextMarshaler interface used by encoding packages
[ "MarshalText", "lets", "Level", "implements", "the", "TextMarshaler", "interface", "used", "by", "encoding", "packages" ]
131980fab91b04c953b9dcb438298a7f06cf76cb
https://github.com/rs/xlog/blob/131980fab91b04c953b9dcb438298a7f06cf76cb/levels.go#L82-L99
133,668
mailjet/mailjet-apiv3-go
smtp_client.go
NewSMTPClient
func NewSMTPClient(apiKeyPublic, apiKeyPrivate string) *SMTPClient { auth := smtp.PlainAuth( "", apiKeyPublic, apiKeyPrivate, HostSMTP, ) return &SMTPClient{ host: fmt.Sprintf("%s:%d", HostSMTP, PortSMTP), auth: auth, } }
go
func NewSMTPClient(apiKeyPublic, apiKeyPrivate string) *SMTPClient { auth := smtp.PlainAuth( "", apiKeyPublic, apiKeyPrivate, HostSMTP, ) return &SMTPClient{ host: fmt.Sprintf("%s:%d", HostSMTP, PortSMTP), auth: auth, } }
[ "func", "NewSMTPClient", "(", "apiKeyPublic", ",", "apiKeyPrivate", "string", ")", "*", "SMTPClient", "{", "auth", ":=", "smtp", ".", "PlainAuth", "(", "\"", "\"", ",", "apiKeyPublic", ",", "apiKeyPrivate", ",", "HostSMTP", ",", ")", "\n", "return", "&", "...
// NewSMTPClient returns a new smtp client wrapper
[ "NewSMTPClient", "returns", "a", "new", "smtp", "client", "wrapper" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/smtp_client.go#L21-L32
133,669
mailjet/mailjet-apiv3-go
fixtures/fixtures.go
New
func New() *Fixtures { f := new(Fixtures) f.data = make(map[interface{}][]byte) fix := reflect.ValueOf(f) for i := 0; i < fix.NumMethod(); i++ { method := fix.Method(i) if method.Type().NumIn() == 0 && method.Type().NumOut() == 2 { values := method.Call([]reflect.Value{}) reflect.ValueOf(f.data).SetMapInd...
go
func New() *Fixtures { f := new(Fixtures) f.data = make(map[interface{}][]byte) fix := reflect.ValueOf(f) for i := 0; i < fix.NumMethod(); i++ { method := fix.Method(i) if method.Type().NumIn() == 0 && method.Type().NumOut() == 2 { values := method.Call([]reflect.Value{}) reflect.ValueOf(f.data).SetMapInd...
[ "func", "New", "(", ")", "*", "Fixtures", "{", "f", ":=", "new", "(", "Fixtures", ")", "\n", "f", ".", "data", "=", "make", "(", "map", "[", "interface", "{", "}", "]", "[", "]", "byte", ")", "\n", "fix", ":=", "reflect", ".", "ValueOf", "(", ...
// New loads fixtures in memory by iterating through its fixture method
[ "New", "loads", "fixtures", "in", "memory", "by", "iterating", "through", "its", "fixture", "method" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/fixtures/fixtures.go#L18-L31
133,670
mailjet/mailjet-apiv3-go
data_api.go
ListData
func (mj *Client) ListData(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error) { url := buildDataURL(mj.apiBase, &DataRequest{SourceType: resource}) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return count, total, err } return mj.httpClient...
go
func (mj *Client) ListData(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error) { url := buildDataURL(mj.apiBase, &DataRequest{SourceType: resource}) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return count, total, err } return mj.httpClient...
[ "func", "(", "mj", "*", "Client", ")", "ListData", "(", "resource", "string", ",", "resp", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "count", ",", "total", "int", ",", "err", "error", ")", "{", "url", ":=", "buildDataURL...
// ListData issues a GET to list the specified data resource // and stores the result in the value pointed to by res. // Filters can be add via functional options.
[ "ListData", "issues", "a", "GET", "to", "list", "the", "specified", "data", "resource", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/data_api.go#L8-L16
133,671
mailjet/mailjet-apiv3-go
data_api.go
GetData
func (mj *Client) GetData(mdr *DataRequest, res interface{}, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, mdr) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return err } _, _, err = mj.httpClient.Send(req).Read(res).Call() return err }
go
func (mj *Client) GetData(mdr *DataRequest, res interface{}, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, mdr) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return err } _, _, err = mj.httpClient.Send(req).Read(res).Call() return err }
[ "func", "(", "mj", "*", "Client", ")", "GetData", "(", "mdr", "*", "DataRequest", ",", "res", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "err", "error", ")", "{", "url", ":=", "buildDataURL", "(", "mj", ".", "apiBase", ...
// GetData issues a GET to view a resource specifying an id // and stores the result in the value pointed to by res. // Filters can be add via functional options. // Without an specified SourceTypeID in MailjetDataRequest, it is the same as ListData.
[ "GetData", "issues", "a", "GET", "to", "view", "a", "resource", "specifying", "an", "id", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", ".", "With...
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/data_api.go#L22-L31
133,672
mailjet/mailjet-apiv3-go
data_api.go
PostData
func (mj *Client) PostData(fmdr *FullDataRequest, res interface{}, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, fmdr.Info) req, err := createRequest("POST", url, fmdr.Payload, nil, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "application/json...
go
func (mj *Client) PostData(fmdr *FullDataRequest, res interface{}, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, fmdr.Info) req, err := createRequest("POST", url, fmdr.Payload, nil, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "application/json...
[ "func", "(", "mj", "*", "Client", ")", "PostData", "(", "fmdr", "*", "FullDataRequest", ",", "res", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "err", "error", ")", "{", "url", ":=", "buildDataURL", "(", "mj", ".", "apiBas...
// PostData issues a POST to create a new data resource // and stores the result in the value pointed to by res. // Filters can be add via functional options.
[ "PostData", "issues", "a", "POST", "to", "create", "a", "new", "data", "resource", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/data_api.go#L36-L51
133,673
mailjet/mailjet-apiv3-go
data_api.go
PutData
func (mj *Client) PutData(fmr *FullDataRequest, onlyFields []string, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, fmr.Info) req, err := createRequest("PUT", url, fmr.Payload, onlyFields, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "applicatio...
go
func (mj *Client) PutData(fmr *FullDataRequest, onlyFields []string, options ...RequestOptions) (err error) { url := buildDataURL(mj.apiBase, fmr.Info) req, err := createRequest("PUT", url, fmr.Payload, onlyFields, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "applicatio...
[ "func", "(", "mj", "*", "Client", ")", "PutData", "(", "fmr", "*", "FullDataRequest", ",", "onlyFields", "[", "]", "string", ",", "options", "...", "RequestOptions", ")", "(", "err", "error", ")", "{", "url", ":=", "buildDataURL", "(", "mj", ".", "apiB...
// PutData is used to update a data resource. // Fields to be updated must be specified by the string array onlyFields. // If onlyFields is nil, all fields except these with the tag read_only, are updated. // Filters can be add via functional options.
[ "PutData", "is", "used", "to", "update", "a", "data", "resource", ".", "Fields", "to", "be", "updated", "must", "be", "specified", "by", "the", "string", "array", "onlyFields", ".", "If", "onlyFields", "is", "nil", "all", "fields", "except", "these", "with...
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/data_api.go#L57-L68
133,674
mailjet/mailjet-apiv3-go
data_api.go
DeleteData
func (mj *Client) DeleteData(mdr *DataRequest) (err error) { url := buildDataURL(mj.apiBase, mdr) req, err := createRequest("DELETE", url, nil, nil) if err != nil { return err } _, _, err = mj.httpClient.Send(req).Call() return err }
go
func (mj *Client) DeleteData(mdr *DataRequest) (err error) { url := buildDataURL(mj.apiBase, mdr) req, err := createRequest("DELETE", url, nil, nil) if err != nil { return err } _, _, err = mj.httpClient.Send(req).Call() return err }
[ "func", "(", "mj", "*", "Client", ")", "DeleteData", "(", "mdr", "*", "DataRequest", ")", "(", "err", "error", ")", "{", "url", ":=", "buildDataURL", "(", "mj", ".", "apiBase", ",", "mdr", ")", "\n", "req", ",", "err", ":=", "createRequest", "(", "...
// DeleteData is used to delete a data resource.
[ "DeleteData", "is", "used", "to", "delete", "a", "data", "resource", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/data_api.go#L71-L81
133,675
mailjet/mailjet-apiv3-go
http_client_mock.go
NewhttpClientMock
func NewhttpClientMock(valid bool) *HTTPClientMock { return &HTTPClientMock{ apiKeyPublic: "apiKeyPublic", apiKeyPrivate: "apiKeyPrivate", client: http.DefaultClient, validCreds: valid, fx: fixtures.New(), CallFunc: func() (int, int, error) { if valid == true { return 1, 1, ni...
go
func NewhttpClientMock(valid bool) *HTTPClientMock { return &HTTPClientMock{ apiKeyPublic: "apiKeyPublic", apiKeyPrivate: "apiKeyPrivate", client: http.DefaultClient, validCreds: valid, fx: fixtures.New(), CallFunc: func() (int, int, error) { if valid == true { return 1, 1, ni...
[ "func", "NewhttpClientMock", "(", "valid", "bool", ")", "*", "HTTPClientMock", "{", "return", "&", "HTTPClientMock", "{", "apiKeyPublic", ":", "\"", "\"", ",", "apiKeyPrivate", ":", "\"", "\"", ",", "client", ":", "http", ".", "DefaultClient", ",", "validCre...
// NewhttpClientMock instanciate new httpClientMock
[ "NewhttpClientMock", "instanciate", "new", "httpClientMock" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client_mock.go#L25-L43
133,676
mailjet/mailjet-apiv3-go
http_client_mock.go
Send
func (c *HTTPClientMock) Send(req *http.Request) HTTPClientInterface { c.request = req return c }
go
func (c *HTTPClientMock) Send(req *http.Request) HTTPClientInterface { c.request = req return c }
[ "func", "(", "c", "*", "HTTPClientMock", ")", "Send", "(", "req", "*", "http", ".", "Request", ")", "HTTPClientInterface", "{", "c", ".", "request", "=", "req", "\n", "return", "c", "\n", "}" ]
// Send data through HTTP with the current configuration
[ "Send", "data", "through", "HTTP", "with", "the", "current", "configuration" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client_mock.go#L66-L69
133,677
mailjet/mailjet-apiv3-go
http_client_mock.go
With
func (c *HTTPClientMock) With(headers map[string]string) HTTPClientInterface { c.headers = headers return c }
go
func (c *HTTPClientMock) With(headers map[string]string) HTTPClientInterface { c.headers = headers return c }
[ "func", "(", "c", "*", "HTTPClientMock", ")", "With", "(", "headers", "map", "[", "string", "]", "string", ")", "HTTPClientInterface", "{", "c", ".", "headers", "=", "headers", "\n", "return", "c", "\n", "}" ]
// With lets you set the http header and returns the httpClientMock with the header modified
[ "With", "lets", "you", "set", "the", "http", "header", "and", "returns", "the", "httpClientMock", "with", "the", "header", "modified" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client_mock.go#L72-L75
133,678
mailjet/mailjet-apiv3-go
http_client_mock.go
Read
func (c *HTTPClientMock) Read(response interface{}) HTTPClientInterface { c.fx.Read(response) return c }
go
func (c *HTTPClientMock) Read(response interface{}) HTTPClientInterface { c.fx.Read(response) return c }
[ "func", "(", "c", "*", "HTTPClientMock", ")", "Read", "(", "response", "interface", "{", "}", ")", "HTTPClientInterface", "{", "c", ".", "fx", ".", "Read", "(", "response", ")", "\n", "return", "c", "\n", "}" ]
// Read allow you to bind the response recieved through the underlying http client
[ "Read", "allow", "you", "to", "bind", "the", "response", "recieved", "through", "the", "underlying", "http", "client" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client_mock.go#L78-L81
133,679
mailjet/mailjet-apiv3-go
http_client_mock.go
SendMailV31
func (c *HTTPClientMock) SendMailV31(req *http.Request) (*http.Response, error) { return c.SendMailV31Func(req) }
go
func (c *HTTPClientMock) SendMailV31(req *http.Request) (*http.Response, error) { return c.SendMailV31Func(req) }
[ "func", "(", "c", "*", "HTTPClientMock", ")", "SendMailV31", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "return", "c", ".", "SendMailV31Func", "(", "req", ")", "\n", "}" ]
// SendMailV31 mock function
[ "SendMailV31", "mock", "function" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client_mock.go#L84-L86
133,680
mailjet/mailjet-apiv3-go
http_client.go
NewHTTPClient
func NewHTTPClient(apiKeyPublic, apiKeyPrivate string) *HTTPClient { return &HTTPClient{ apiKeyPublic: apiKeyPublic, apiKeyPrivate: apiKeyPrivate, client: http.DefaultClient, } }
go
func NewHTTPClient(apiKeyPublic, apiKeyPrivate string) *HTTPClient { return &HTTPClient{ apiKeyPublic: apiKeyPublic, apiKeyPrivate: apiKeyPrivate, client: http.DefaultClient, } }
[ "func", "NewHTTPClient", "(", "apiKeyPublic", ",", "apiKeyPrivate", "string", ")", "*", "HTTPClient", "{", "return", "&", "HTTPClient", "{", "apiKeyPublic", ":", "apiKeyPublic", ",", "apiKeyPrivate", ":", "apiKeyPrivate", ",", "client", ":", "http", ".", "Defaul...
// NewHTTPClient returns a new httpClient
[ "NewHTTPClient", "returns", "a", "new", "httpClient" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client.go#L21-L27
133,681
mailjet/mailjet-apiv3-go
http_client.go
Send
func (c *HTTPClient) Send(req *http.Request) HTTPClientInterface { c.request = req return c }
go
func (c *HTTPClient) Send(req *http.Request) HTTPClientInterface { c.request = req return c }
[ "func", "(", "c", "*", "HTTPClient", ")", "Send", "(", "req", "*", "http", ".", "Request", ")", "HTTPClientInterface", "{", "c", ".", "request", "=", "req", "\n", "return", "c", "\n", "}" ]
// Send binds the request to the underlying http client
[ "Send", "binds", "the", "request", "to", "the", "underlying", "http", "client" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client.go#L50-L53
133,682
mailjet/mailjet-apiv3-go
http_client.go
With
func (c *HTTPClient) With(headers map[string]string) HTTPClientInterface { c.headers = headers return c }
go
func (c *HTTPClient) With(headers map[string]string) HTTPClientInterface { c.headers = headers return c }
[ "func", "(", "c", "*", "HTTPClient", ")", "With", "(", "headers", "map", "[", "string", "]", "string", ")", "HTTPClientInterface", "{", "c", ".", "headers", "=", "headers", "\n", "return", "c", "\n", "}" ]
// With binds the header to the underlying http client
[ "With", "binds", "the", "header", "to", "the", "underlying", "http", "client" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client.go#L56-L59
133,683
mailjet/mailjet-apiv3-go
http_client.go
SendMailV31
func (c *HTTPClient) SendMailV31(req *http.Request) (*http.Response, error) { res, err := c.Client().Do(req) return res, err }
go
func (c *HTTPClient) SendMailV31(req *http.Request) (*http.Response, error) { res, err := c.Client().Do(req) return res, err }
[ "func", "(", "c", "*", "HTTPClient", ")", "SendMailV31", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "Client", "(", ")", ".", "Do", "(", "req", ")",...
// SendMailV31 simply calls the underlying http client.Do function
[ "SendMailV31", "simply", "calls", "the", "underlying", "http", "client", ".", "Do", "function" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client.go#L62-L65
133,684
mailjet/mailjet-apiv3-go
http_client.go
Call
func (c *HTTPClient) Call() (count, total int, err error) { defer c.reset() for key, value := range c.headers { c.request.Header.Add(key, value) } resp, err := c.doRequest(c.request) if resp != nil { defer resp.Body.Close() } if err != nil { return count, total, err } else if resp == nil { return coun...
go
func (c *HTTPClient) Call() (count, total int, err error) { defer c.reset() for key, value := range c.headers { c.request.Header.Add(key, value) } resp, err := c.doRequest(c.request) if resp != nil { defer resp.Body.Close() } if err != nil { return count, total, err } else if resp == nil { return coun...
[ "func", "(", "c", "*", "HTTPClient", ")", "Call", "(", ")", "(", "count", ",", "total", "int", ",", "err", "error", ")", "{", "defer", "c", ".", "reset", "(", ")", "\n", "for", "key", ",", "value", ":=", "range", "c", ".", "headers", "{", "c", ...
// Call execute the HTTP call to the API
[ "Call", "execute", "the", "HTTP", "call", "to", "the", "API" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/http_client.go#L74-L103
133,685
mailjet/mailjet-apiv3-go
core.go
createRequest
func createRequest(method string, url string, payload interface{}, onlyFields []string, options ...RequestOptions) (req *http.Request, err error) { body, err := convertPayload(payload, onlyFields) if err != nil { return req, fmt.Errorf("creating request: %s\n", err) } req, err = http.NewRequest(method, url, by...
go
func createRequest(method string, url string, payload interface{}, onlyFields []string, options ...RequestOptions) (req *http.Request, err error) { body, err := convertPayload(payload, onlyFields) if err != nil { return req, fmt.Errorf("creating request: %s\n", err) } req, err = http.NewRequest(method, url, by...
[ "func", "createRequest", "(", "method", "string", ",", "url", "string", ",", "payload", "interface", "{", "}", ",", "onlyFields", "[", "]", "string", ",", "options", "...", "RequestOptions", ")", "(", "req", "*", "http", ".", "Request", ",", "err", "erro...
// createRequest is the main core function.
[ "createRequest", "is", "the", "main", "core", "function", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L40-L58
133,686
mailjet/mailjet-apiv3-go
core.go
userAgent
func userAgent(req *http.Request) { ua := fmt.Sprintf("%s/%s;%s", UserAgentBase, UserAgentVersion, runtime.Version(), ) req.Header.Add("User-Agent", ua) }
go
func userAgent(req *http.Request) { ua := fmt.Sprintf("%s/%s;%s", UserAgentBase, UserAgentVersion, runtime.Version(), ) req.Header.Add("User-Agent", ua) }
[ "func", "userAgent", "(", "req", "*", "http", ".", "Request", ")", "{", "ua", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "UserAgentBase", ",", "UserAgentVersion", ",", "runtime", ".", "Version", "(", ")", ",", ")", "\n", "req", ".", "Header",...
// userAgent add the User-Agent value to the request header.
[ "userAgent", "add", "the", "User", "-", "Agent", "value", "to", "the", "request", "header", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L147-L154
133,687
mailjet/mailjet-apiv3-go
core.go
readJSONResult
func readJSONResult(r io.Reader, data interface{}) (int, int, error) { var res RequestResult res.Data = data jsonBlob, err := ioutil.ReadAll(r) // ReadAll and store in jsonBlob (mandatory if we want to unmarshal two times) if err != nil { return 0, 0, fmt.Errorf("Error reading API response: %s", err) } if Debu...
go
func readJSONResult(r io.Reader, data interface{}) (int, int, error) { var res RequestResult res.Data = data jsonBlob, err := ioutil.ReadAll(r) // ReadAll and store in jsonBlob (mandatory if we want to unmarshal two times) if err != nil { return 0, 0, fmt.Errorf("Error reading API response: %s", err) } if Debu...
[ "func", "readJSONResult", "(", "r", "io", ".", "Reader", ",", "data", "interface", "{", "}", ")", "(", "int", ",", "int", ",", "error", ")", "{", "var", "res", "RequestResult", "\n", "res", ".", "Data", "=", "data", "\n\n", "jsonBlob", ",", "err", ...
// readJsonResult decodes the API response, returns Count and Total values // and stores the Data in the value pointed to by data.
[ "readJsonResult", "decodes", "the", "API", "response", "returns", "Count", "and", "Total", "values", "and", "stores", "the", "Data", "in", "the", "value", "pointed", "to", "by", "data", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L197-L220
133,688
mailjet/mailjet-apiv3-go
core.go
doRequest
func (c *HTTPClient) doRequest(req *http.Request) (resp *http.Response, err error) { debugRequest(req) //DEBUG req.SetBasicAuth(c.apiKeyPublic, c.apiKeyPrivate) for attempt := 0; attempt < NbAttempt; attempt++ { if resp != nil { resp.Body.Close() } resp, err = c.client.Do(req) if err != nil || (resp != ni...
go
func (c *HTTPClient) doRequest(req *http.Request) (resp *http.Response, err error) { debugRequest(req) //DEBUG req.SetBasicAuth(c.apiKeyPublic, c.apiKeyPrivate) for attempt := 0; attempt < NbAttempt; attempt++ { if resp != nil { resp.Body.Close() } resp, err = c.client.Do(req) if err != nil || (resp != ni...
[ "func", "(", "c", "*", "HTTPClient", ")", "doRequest", "(", "req", "*", "http", ".", "Request", ")", "(", "resp", "*", "http", ".", "Response", ",", "err", "error", ")", "{", "debugRequest", "(", "req", ")", "//DEBUG", "\n", "req", ".", "SetBasicAuth...
// doRequest is called to execute the request. Authentification is set // with the public key and the secret key specified in MailjetClient.
[ "doRequest", "is", "called", "to", "execute", "the", "request", ".", "Authentification", "is", "set", "with", "the", "public", "key", "and", "the", "secret", "key", "specified", "in", "MailjetClient", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L228-L246
133,689
mailjet/mailjet-apiv3-go
core.go
debugRequest
func debugRequest(req *http.Request) { if DebugLevel > LevelNone && req != nil { log.Printf("Method used is: %s\n", req.Method) log.Printf("Final URL is: %s\n", req.URL) log.Printf("Header is: %s\n", req.Header) } }
go
func debugRequest(req *http.Request) { if DebugLevel > LevelNone && req != nil { log.Printf("Method used is: %s\n", req.Method) log.Printf("Final URL is: %s\n", req.URL) log.Printf("Header is: %s\n", req.Header) } }
[ "func", "debugRequest", "(", "req", "*", "http", ".", "Request", ")", "{", "if", "DebugLevel", ">", "LevelNone", "&&", "req", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "req", ".", "Method", ")", "\n", "log", ".", "Printf"...
// debugRequest is a custom dump of the request. // Method used, final URl called, and Header content are logged.
[ "debugRequest", "is", "a", "custom", "dump", "of", "the", "request", ".", "Method", "used", "final", "URl", "called", "and", "Header", "content", "are", "logged", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L265-L271
133,690
mailjet/mailjet-apiv3-go
core.go
debugResponse
func debugResponse(resp *http.Response) { if DebugLevel > LevelNone && resp != nil { log.Printf("Status is: %s\n", resp.Status) log.Printf("Header is: %s\n", resp.Header) } }
go
func debugResponse(resp *http.Response) { if DebugLevel > LevelNone && resp != nil { log.Printf("Status is: %s\n", resp.Status) log.Printf("Header is: %s\n", resp.Header) } }
[ "func", "debugResponse", "(", "resp", "*", "http", ".", "Response", ")", "{", "if", "DebugLevel", ">", "LevelNone", "&&", "resp", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "resp", ".", "Status", ")", "\n", "log", ".", "Pr...
// debugResponse is a custom dump of the response. // Status and Header content are logged.
[ "debugResponse", "is", "a", "custom", "dump", "of", "the", "response", ".", "Status", "and", "Header", "content", "are", "logged", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/core.go#L275-L280
133,691
mailjet/mailjet-apiv3-go
mailjet_client.go
NewMailjetClient
func NewMailjetClient(apiKeyPublic, apiKeyPrivate string, baseURL ...string) *Client { httpClient := NewHTTPClient(apiKeyPublic, apiKeyPrivate) smtpClient := NewSMTPClient(apiKeyPublic, apiKeyPrivate) client := &Client{ httpClient: httpClient, smtpClient: smtpClient, apiBase: apiBase, } if len(baseURL) ...
go
func NewMailjetClient(apiKeyPublic, apiKeyPrivate string, baseURL ...string) *Client { httpClient := NewHTTPClient(apiKeyPublic, apiKeyPrivate) smtpClient := NewSMTPClient(apiKeyPublic, apiKeyPrivate) client := &Client{ httpClient: httpClient, smtpClient: smtpClient, apiBase: apiBase, } if len(baseURL) ...
[ "func", "NewMailjetClient", "(", "apiKeyPublic", ",", "apiKeyPrivate", "string", ",", "baseURL", "...", "string", ")", "*", "Client", "{", "httpClient", ":=", "NewHTTPClient", "(", "apiKeyPublic", ",", "apiKeyPrivate", ")", "\n", "smtpClient", ":=", "NewSMTPClient...
// NewMailjetClient returns a new MailjetClient using an public apikey // and an secret apikey to be used when authenticating to API.
[ "NewMailjetClient", "returns", "a", "new", "MailjetClient", "using", "an", "public", "apikey", "and", "an", "secret", "apikey", "to", "be", "used", "when", "authenticating", "to", "API", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L23-L37
133,692
mailjet/mailjet-apiv3-go
mailjet_client.go
SetURL
func (c *Client) SetURL(baseURL string) { c.Lock() defer c.Unlock() c.apiBase = baseURL }
go
func (c *Client) SetURL(baseURL string) { c.Lock() defer c.Unlock() c.apiBase = baseURL }
[ "func", "(", "c", "*", "Client", ")", "SetURL", "(", "baseURL", "string", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "apiBase", "=", "baseURL", "\n", "}" ]
// SetURL function to set the base url of the wrapper instance
[ "SetURL", "function", "to", "set", "the", "base", "url", "of", "the", "wrapper", "instance" ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L71-L75
133,693
mailjet/mailjet-apiv3-go
mailjet_client.go
SetClient
func (c *Client) SetClient(client *http.Client) { c.Lock() defer c.Unlock() c.httpClient.SetClient(client) }
go
func (c *Client) SetClient(client *http.Client) { c.Lock() defer c.Unlock() c.httpClient.SetClient(client) }
[ "func", "(", "c", "*", "Client", ")", "SetClient", "(", "client", "*", "http", ".", "Client", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "httpClient", ".", "SetClient", "(", "client", ")", ...
// SetClient allows to customize http client.
[ "SetClient", "allows", "to", "customize", "http", "client", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L83-L87
133,694
mailjet/mailjet-apiv3-go
mailjet_client.go
Filter
func Filter(key, value string) RequestOptions { return func(req *http.Request) { q := req.URL.Query() q.Add(key, value) req.URL.RawQuery = strings.Replace(q.Encode(), "%2B", "+", 1) } }
go
func Filter(key, value string) RequestOptions { return func(req *http.Request) { q := req.URL.Query() q.Add(key, value) req.URL.RawQuery = strings.Replace(q.Encode(), "%2B", "+", 1) } }
[ "func", "Filter", "(", "key", ",", "value", "string", ")", "RequestOptions", "{", "return", "func", "(", "req", "*", "http", ".", "Request", ")", "{", "q", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "q", ".", "Add", "(", "key", ",", ...
// Filter applies a filter with the defined key and value.
[ "Filter", "applies", "a", "filter", "with", "the", "defined", "key", "and", "value", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L90-L96
133,695
mailjet/mailjet-apiv3-go
mailjet_client.go
Sort
func Sort(value string, order SortOrder) RequestOptions { if order == SortDesc { value = value + "+DESC" } return Filter("Sort", value) }
go
func Sort(value string, order SortOrder) RequestOptions { if order == SortDesc { value = value + "+DESC" } return Filter("Sort", value) }
[ "func", "Sort", "(", "value", "string", ",", "order", "SortOrder", ")", "RequestOptions", "{", "if", "order", "==", "SortDesc", "{", "value", "=", "value", "+", "\"", "\"", "\n", "}", "\n", "return", "Filter", "(", "\"", "\"", ",", "value", ")", "\n"...
// Sort applies the Sort filter to the request.
[ "Sort", "applies", "the", "Sort", "filter", "to", "the", "request", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L116-L121
133,696
mailjet/mailjet-apiv3-go
mailjet_client.go
List
func (c *Client) List(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error) { url := buildURL(c.apiBase, &Request{Resource: resource}) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return count, total, err } c.Lock() defer c.Unlock() return c...
go
func (c *Client) List(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error) { url := buildURL(c.apiBase, &Request{Resource: resource}) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return count, total, err } c.Lock() defer c.Unlock() return c...
[ "func", "(", "c", "*", "Client", ")", "List", "(", "resource", "string", ",", "resp", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "count", ",", "total", "int", ",", "err", "error", ")", "{", "url", ":=", "buildURL", "(",...
// List issues a GET to list the specified resource // and stores the result in the value pointed to by res. // Filters can be add via functional options.
[ "List", "issues", "a", "GET", "to", "list", "the", "specified", "resource", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L126-L136
133,697
mailjet/mailjet-apiv3-go
mailjet_client.go
Get
func (c *Client) Get(mr *Request, resp interface{}, options ...RequestOptions) (err error) { url := buildURL(c.apiBase, mr) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return err } c.Lock() defer c.Unlock() _, _, err = c.httpClient.Send(req).Read(resp).Call() return err }
go
func (c *Client) Get(mr *Request, resp interface{}, options ...RequestOptions) (err error) { url := buildURL(c.apiBase, mr) req, err := createRequest("GET", url, nil, nil, options...) if err != nil { return err } c.Lock() defer c.Unlock() _, _, err = c.httpClient.Send(req).Read(resp).Call() return err }
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "mr", "*", "Request", ",", "resp", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "err", "error", ")", "{", "url", ":=", "buildURL", "(", "c", ".", "apiBase", ",", "mr", ...
// Get issues a GET to view a resource specifying an id // and stores the result in the value pointed to by res. // Filters can be add via functional options. // Without an specified ID in MailjetRequest, it is the same as List.
[ "Get", "issues", "a", "GET", "to", "view", "a", "resource", "specifying", "an", "id", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", ".", "Without"...
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L142-L153
133,698
mailjet/mailjet-apiv3-go
mailjet_client.go
Post
func (c *Client) Post(fmr *FullRequest, resp interface{}, options ...RequestOptions) (err error) { url := buildURL(c.apiBase, fmr.Info) req, err := createRequest("POST", url, fmr.Payload, nil, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "application/json"} c.Lock() de...
go
func (c *Client) Post(fmr *FullRequest, resp interface{}, options ...RequestOptions) (err error) { url := buildURL(c.apiBase, fmr.Info) req, err := createRequest("POST", url, fmr.Payload, nil, options...) if err != nil { return err } headers := map[string]string{"Content-Type": "application/json"} c.Lock() de...
[ "func", "(", "c", "*", "Client", ")", "Post", "(", "fmr", "*", "FullRequest", ",", "resp", "interface", "{", "}", ",", "options", "...", "RequestOptions", ")", "(", "err", "error", ")", "{", "url", ":=", "buildURL", "(", "c", ".", "apiBase", ",", "...
// Post issues a POST to create a new resource // and stores the result in the value pointed to by res. // Filters can be add via functional options.
[ "Post", "issues", "a", "POST", "to", "create", "a", "new", "resource", "and", "stores", "the", "result", "in", "the", "value", "pointed", "to", "by", "res", ".", "Filters", "can", "be", "add", "via", "functional", "options", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L158-L170
133,699
mailjet/mailjet-apiv3-go
mailjet_client.go
Delete
func (c *Client) Delete(mr *Request) (err error) { url := buildURL(c.apiBase, mr) req, err := createRequest("DELETE", url, nil, nil) if err != nil { return err } c.Lock() defer c.Unlock() _, _, err = c.httpClient.Send(req).Call() return err }
go
func (c *Client) Delete(mr *Request) (err error) { url := buildURL(c.apiBase, mr) req, err := createRequest("DELETE", url, nil, nil) if err != nil { return err } c.Lock() defer c.Unlock() _, _, err = c.httpClient.Send(req).Call() return err }
[ "func", "(", "c", "*", "Client", ")", "Delete", "(", "mr", "*", "Request", ")", "(", "err", "error", ")", "{", "url", ":=", "buildURL", "(", "c", ".", "apiBase", ",", "mr", ")", "\n", "req", ",", "err", ":=", "createRequest", "(", "\"", "\"", "...
// Delete is used to delete a resource.
[ "Delete", "is", "used", "to", "delete", "a", "resource", "." ]
e508c28bf11623de2171a2331fc673391b066867
https://github.com/mailjet/mailjet-apiv3-go/blob/e508c28bf11623de2171a2331fc673391b066867/mailjet_client.go#L191-L202