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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
136,900
netrack/openflow
ofp/port.go
WriteTo
func (p *PortMod) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}, p.HWAddr, pad2{}, p.Config, p.Mask, p.Advertise, pad4{}, ) }
go
func (p *PortMod) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}, p.HWAddr, pad2{}, p.Config, p.Mask, p.Advertise, pad4{}, ) }
[ "func", "(", "p", "*", "PortMod", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "WriteTo", "(", "w", ",", "p", ".", "PortNo", ",", "pad4", "{", "}", ",", "p", ".", "HWAddr",...
// WriteTo implements io.WriterTo interface. It serializes the port // modification request into the wire format.
[ "WriteTo", "implements", "io", ".", "WriterTo", "interface", ".", "It", "serializes", "the", "port", "modification", "request", "into", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L382-L386
136,901
netrack/openflow
ofp/port.go
ReadFrom
func (p *PortMod) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.HWAddr, &defaultPad2, &p.Config, &p.Mask, &p.Advertise, &defaultPad4, ) }
go
func (p *PortMod) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.HWAddr, &defaultPad2, &p.Config, &p.Mask, &p.Advertise, &defaultPad4, ) }
[ "func", "(", "p", "*", "PortMod", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "ReadFrom", "(", "r", ",", "&", "p", ".", "PortNo", ",", "&", "defaultPad4", ",", "&", "p", ...
// ReadFrom implements io.ReaderFrom interfaace. It deserializes the // port modification request from the wire format.
[ "ReadFrom", "implements", "io", ".", "ReaderFrom", "interfaace", ".", "It", "deserializes", "the", "port", "modification", "request", "from", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L390-L394
136,902
netrack/openflow
ofp/port.go
WriteTo
func (p *PortStatus) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.Reason, pad7{}, &p.Port) }
go
func (p *PortStatus) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.Reason, pad7{}, &p.Port) }
[ "func", "(", "p", "*", "PortStatus", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "WriteTo", "(", "w", ",", "p", ".", "Reason", ",", "pad7", "{", "}", ",", "&", "p", ".", ...
// WriteTo implements io.WriterTo interface. It serializes the // port status into the wire format.
[ "WriteTo", "implements", "io", ".", "WriterTo", "interface", ".", "It", "serializes", "the", "port", "status", "into", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L423-L425
136,903
netrack/openflow
ofp/port.go
ReadFrom
func (p *PortStatus) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.Reason, &defaultPad7, &p.Port) }
go
func (p *PortStatus) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.Reason, &defaultPad7, &p.Port) }
[ "func", "(", "p", "*", "PortStatus", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "ReadFrom", "(", "r", ",", "&", "p", ".", "Reason", ",", "&", "defaultPad7", ",", "&", "p",...
// ReadFrom implements io.ReaderFrom interface. It deserializes the // port status from the wire format.
[ "ReadFrom", "implements", "io", ".", "ReaderFrom", "interface", ".", "It", "deserializes", "the", "port", "status", "from", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L429-L431
136,904
netrack/openflow
ofp/port.go
WriteTo
func (p *PortStatsRequest) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}) }
go
func (p *PortStatsRequest) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}) }
[ "func", "(", "p", "*", "PortStatsRequest", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "WriteTo", "(", "w", ",", "p", ".", "PortNo", ",", "pad4", "{", "}", ")", "\n", "}" ]
// WriteTo implements io.WriterTo interface. It serializes the port // status request into the wire format.
[ "WriteTo", "implements", "io", ".", "WriterTo", "interface", ".", "It", "serializes", "the", "port", "status", "request", "into", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L452-L454
136,905
netrack/openflow
ofp/port.go
ReadFrom
func (p *PortStatsRequest) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4) }
go
func (p *PortStatsRequest) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4) }
[ "func", "(", "p", "*", "PortStatsRequest", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "ReadFrom", "(", "r", ",", "&", "p", ".", "PortNo", ",", "&", "defaultPad4", ")", "\n",...
// ReadFrom implements io.ReaderFrom interface. It deserializes // the port stats request from the wire format.
[ "ReadFrom", "implements", "io", ".", "ReaderFrom", "interface", ".", "It", "deserializes", "the", "port", "stats", "request", "from", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L458-L460
136,906
netrack/openflow
ofp/port.go
WriteTo
func (p *PortStats) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}, p.RxPackets, p.TxPackets, p.RxBytes, p.TxBytes, p.RxDropped, p.TxDropped, p.RxErrors, p.TxErrors, p.RxFrameErr, p.RxOverErr, p.RxCrcErr, p.Collisions, p.DurationSec, p.DurationNSec, ) }
go
func (p *PortStats) WriteTo(w io.Writer) (int64, error) { return encoding.WriteTo(w, p.PortNo, pad4{}, p.RxPackets, p.TxPackets, p.RxBytes, p.TxBytes, p.RxDropped, p.TxDropped, p.RxErrors, p.TxErrors, p.RxFrameErr, p.RxOverErr, p.RxCrcErr, p.Collisions, p.DurationSec, p.DurationNSec, ) }
[ "func", "(", "p", "*", "PortStats", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "WriteTo", "(", "w", ",", "p", ".", "PortNo", ",", "pad4", "{", "}", ",", "p", ".", "RxPack...
// WriteTo implements io.WriterTo interface. It serializes the port stats // into the wire format.
[ "WriteTo", "implements", "io", ".", "WriterTo", "interface", ".", "It", "serializes", "the", "port", "stats", "into", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L516-L522
136,907
netrack/openflow
ofp/port.go
ReadFrom
func (p *PortStats) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.RxPackets, &p.TxPackets, &p.RxBytes, &p.TxBytes, &p.RxDropped, &p.TxDropped, &p.RxErrors, &p.TxErrors, &p.RxFrameErr, &p.RxOverErr, &p.RxCrcErr, &p.Collisions, &p.DurationSec, &p.DurationNSec, ) }
go
func (p *PortStats) ReadFrom(r io.Reader) (int64, error) { return encoding.ReadFrom(r, &p.PortNo, &defaultPad4, &p.RxPackets, &p.TxPackets, &p.RxBytes, &p.TxBytes, &p.RxDropped, &p.TxDropped, &p.RxErrors, &p.TxErrors, &p.RxFrameErr, &p.RxOverErr, &p.RxCrcErr, &p.Collisions, &p.DurationSec, &p.DurationNSec, ) }
[ "func", "(", "p", "*", "PortStats", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "return", "encoding", ".", "ReadFrom", "(", "r", ",", "&", "p", ".", "PortNo", ",", "&", "defaultPad4", ",", "&", "p", ...
// ReadFrom implements io.ReaderFrom interface. It deserializes the port // stats from the wire format.
[ "ReadFrom", "implements", "io", ".", "ReaderFrom", "interface", ".", "It", "deserializes", "the", "port", "stats", "from", "the", "wire", "format", "." ]
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofp/port.go#L526-L532
136,908
netrack/openflow
ofputil/handler.go
EchoHandler
func EchoHandler(h of.Handler) of.Handler { fn := func(rw of.ResponseWriter, r *of.Request) { var req ofp.EchoRequest // Try to parse the retrieved request to copy // the data of echo message into the request. _, err := req.ReadFrom(r.Body) if err != nil { text := "ofputil: failed to read the message: %v...
go
func EchoHandler(h of.Handler) of.Handler { fn := func(rw of.ResponseWriter, r *of.Request) { var req ofp.EchoRequest // Try to parse the retrieved request to copy // the data of echo message into the request. _, err := req.ReadFrom(r.Body) if err != nil { text := "ofputil: failed to read the message: %v...
[ "func", "EchoHandler", "(", "h", "of", ".", "Handler", ")", "of", ".", "Handler", "{", "fn", ":=", "func", "(", "rw", "of", ".", "ResponseWriter", ",", "r", "*", "of", ".", "Request", ")", "{", "var", "req", "ofp", ".", "EchoRequest", "\n\n", "// T...
// EchoHandler returns a request handler that replies on // each request with a echo message with the same data // as it was retrieved in the original message. // // The method accepts optional handler, that will executed // in case of successful message submission.
[ "EchoHandler", "returns", "a", "request", "handler", "that", "replies", "on", "each", "request", "with", "a", "echo", "message", "with", "the", "same", "data", "as", "it", "was", "retrieved", "in", "the", "original", "message", ".", "The", "method", "accepts...
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofputil/handler.go#L16-L42
136,909
netrack/openflow
ofputil/handler.go
HelloHandler
func HelloHandler(version uint8, h of.Handler) of.Handler { fn := func(rw of.ResponseWriter, r *of.Request) { // Copy the header of retrieved message, // including the trasnaction identifier. header := r.Header.Copy() header.Version = version // Send a response to the called with a version // supported ve...
go
func HelloHandler(version uint8, h of.Handler) of.Handler { fn := func(rw of.ResponseWriter, r *of.Request) { // Copy the header of retrieved message, // including the trasnaction identifier. header := r.Header.Copy() header.Version = version // Send a response to the called with a version // supported ve...
[ "func", "HelloHandler", "(", "version", "uint8", ",", "h", "of", ".", "Handler", ")", "of", ".", "Handler", "{", "fn", ":=", "func", "(", "rw", "of", ".", "ResponseWriter", ",", "r", "*", "of", ".", "Request", ")", "{", "// Copy the header of retrieved m...
// HelloHandler returns a simple request handler that replies // to each request with hello message of the specified version. // // The method accepts optional handler, that will executed // in case of successful message submission.
[ "HelloHandler", "returns", "a", "simple", "request", "handler", "that", "replies", "to", "each", "request", "with", "hello", "message", "of", "the", "specified", "version", ".", "The", "method", "accepts", "optional", "handler", "that", "will", "executed", "in",...
9304e84a549fd9332c278eac544f5efff47c9ab8
https://github.com/netrack/openflow/blob/9304e84a549fd9332c278eac544f5efff47c9ab8/ofputil/handler.go#L49-L66
136,910
Wattpad/sqsconsumer
middleware/sns_unwrap.go
UnwrapSNSMessage
func UnwrapSNSMessage() MessageHandlerDecorator { return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { return func(ctx context.Context, msg string) error { var e snsEnvelope err := json.Unmarshal([]byte(msg), &e) if err == nil && isSNSMessage(e) { return fn(ctx, e.Message) ...
go
func UnwrapSNSMessage() MessageHandlerDecorator { return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { return func(ctx context.Context, msg string) error { var e snsEnvelope err := json.Unmarshal([]byte(msg), &e) if err == nil && isSNSMessage(e) { return fn(ctx, e.Message) ...
[ "func", "UnwrapSNSMessage", "(", ")", "MessageHandlerDecorator", "{", "return", "func", "(", "fn", "sqsconsumer", ".", "MessageHandlerFunc", ")", "sqsconsumer", ".", "MessageHandlerFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "msg", ...
// UnwrapSNSMessage decorates a MessageHandler to unwrap messages sent via SNS
[ "UnwrapSNSMessage", "decorates", "a", "MessageHandler", "to", "unwrap", "messages", "sent", "via", "SNS" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/sns_unwrap.go#L11-L24
136,911
Wattpad/sqsconsumer
cleanup_delete.go
NewBatchDeleter
func NewBatchDeleter(ctx context.Context, wg *sync.WaitGroup, s *SQSService, every, drainTimeout time.Duration) chan<- *sqs.Message { dq := &deleteQueue{ svc: s, accumulationTimeout: every, drainTimeout: drainTimeout, queue: make(chan *sqs.Message), } wg.Add(1) go dq.sta...
go
func NewBatchDeleter(ctx context.Context, wg *sync.WaitGroup, s *SQSService, every, drainTimeout time.Duration) chan<- *sqs.Message { dq := &deleteQueue{ svc: s, accumulationTimeout: every, drainTimeout: drainTimeout, queue: make(chan *sqs.Message), } wg.Add(1) go dq.sta...
[ "func", "NewBatchDeleter", "(", "ctx", "context", ".", "Context", ",", "wg", "*", "sync", ".", "WaitGroup", ",", "s", "*", "SQSService", ",", "every", ",", "drainTimeout", "time", ".", "Duration", ")", "chan", "<-", "*", "sqs", ".", "Message", "{", "dq...
// NewBatchDeleter starts a batch deleter routine that deletes messages after they are sent to the returned channel
[ "NewBatchDeleter", "starts", "a", "batch", "deleter", "routine", "that", "deletes", "messages", "after", "they", "are", "sent", "to", "the", "returned", "channel" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_delete.go#L22-L32
136,912
Wattpad/sqsconsumer
cleanup_delete.go
deleteBatch
func (dq *deleteQueue) deleteBatch(msgs []*sqs.DeleteMessageBatchRequestEntry) ([]*sqs.DeleteMessageBatchRequestEntry, error) { req := &sqs.DeleteMessageBatchInput{ QueueUrl: dq.svc.URL, Entries: msgs, } resp, err := dq.svc.Svc.DeleteMessageBatch(req) if err != nil { dq.svc.Logger("Error deleting messages: ...
go
func (dq *deleteQueue) deleteBatch(msgs []*sqs.DeleteMessageBatchRequestEntry) ([]*sqs.DeleteMessageBatchRequestEntry, error) { req := &sqs.DeleteMessageBatchInput{ QueueUrl: dq.svc.URL, Entries: msgs, } resp, err := dq.svc.Svc.DeleteMessageBatch(req) if err != nil { dq.svc.Logger("Error deleting messages: ...
[ "func", "(", "dq", "*", "deleteQueue", ")", "deleteBatch", "(", "msgs", "[", "]", "*", "sqs", ".", "DeleteMessageBatchRequestEntry", ")", "(", "[", "]", "*", "sqs", ".", "DeleteMessageBatchRequestEntry", ",", "error", ")", "{", "req", ":=", "&", "sqs", "...
// deleteBatch deletes a batch of messages and returns the list of messages that failed to delete or an error for overall failure.
[ "deleteBatch", "deletes", "a", "batch", "of", "messages", "and", "returns", "the", "list", "of", "messages", "that", "failed", "to", "delete", "or", "an", "error", "for", "overall", "failure", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_delete.go#L51-L73
136,913
Wattpad/sqsconsumer
cleanup_delete.go
deleteFromPending
func (dq *deleteQueue) deleteFromPending() { dq.Lock() defer dq.Unlock() n := len(dq.entries) if n > awsBatchSizeLimit { n = awsBatchSizeLimit } fails, err := dq.deleteBatch(dq.entries[:n]) if err != nil { dq.svc.Logger("Error deleting batch: %s", err) return } dq.entries = dq.entries[n:] if len(fail...
go
func (dq *deleteQueue) deleteFromPending() { dq.Lock() defer dq.Unlock() n := len(dq.entries) if n > awsBatchSizeLimit { n = awsBatchSizeLimit } fails, err := dq.deleteBatch(dq.entries[:n]) if err != nil { dq.svc.Logger("Error deleting batch: %s", err) return } dq.entries = dq.entries[n:] if len(fail...
[ "func", "(", "dq", "*", "deleteQueue", ")", "deleteFromPending", "(", ")", "{", "dq", ".", "Lock", "(", ")", "\n", "defer", "dq", ".", "Unlock", "(", ")", "\n\n", "n", ":=", "len", "(", "dq", ".", "entries", ")", "\n", "if", "n", ">", "awsBatchSi...
// deleteFromPending prepares a batch of messages and deletes them
[ "deleteFromPending", "prepares", "a", "batch", "of", "messages", "and", "deletes", "them" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_delete.go#L76-L95
136,914
Wattpad/sqsconsumer
router/router.go
Add
func (t Type) Add(route string, h sqsconsumer.MessageHandlerFunc) { t[route] = h }
go
func (t Type) Add(route string, h sqsconsumer.MessageHandlerFunc) { t[route] = h }
[ "func", "(", "t", "Type", ")", "Add", "(", "route", "string", ",", "h", "sqsconsumer", ".", "MessageHandlerFunc", ")", "{", "t", "[", "route", "]", "=", "h", "\n", "}" ]
// Add registers a handler func for a specific message type
[ "Add", "registers", "a", "handler", "func", "for", "a", "specific", "message", "type" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/router/router.go#L20-L22
136,915
Wattpad/sqsconsumer
router/router.go
Handler
func (t Type) Handler(ctx context.Context, msg string) error { var tm typedMessage err := json.Unmarshal([]byte(msg), &tm) if err != nil { return err } if tm.Type == "" { return RouteNotFoundError{tm.Type} } fn, ok := t[tm.Type] if !ok { return RouteNotFoundError{tm.Type} } return fn(ctx, msg) }
go
func (t Type) Handler(ctx context.Context, msg string) error { var tm typedMessage err := json.Unmarshal([]byte(msg), &tm) if err != nil { return err } if tm.Type == "" { return RouteNotFoundError{tm.Type} } fn, ok := t[tm.Type] if !ok { return RouteNotFoundError{tm.Type} } return fn(ctx, msg) }
[ "func", "(", "t", "Type", ")", "Handler", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ")", "error", "{", "var", "tm", "typedMessage", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "msg", ")", ",", "&", ...
// Handler handles JSON messages and routes the message to an appropriate handler func based on the "type" property of the message
[ "Handler", "handles", "JSON", "messages", "and", "routes", "the", "message", "to", "an", "appropriate", "handler", "func", "based", "on", "the", "type", "property", "of", "the", "message" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/router/router.go#L25-L41
136,916
Wattpad/sqsconsumer
sqs_service.go
SQSServiceForQueue
func SQSServiceForQueue(queueName string, opts ...AWSConfigOption) (*SQSService, error) { conf := &aws.Config{} for _, o := range opts { o(conf) } svc := sqs.New(session.New(conf)) s := &SQSService{ Svc: svc, Logger: NoopLogger, } var url *string var err error if url, err = SetupQueue(svc, queueName...
go
func SQSServiceForQueue(queueName string, opts ...AWSConfigOption) (*SQSService, error) { conf := &aws.Config{} for _, o := range opts { o(conf) } svc := sqs.New(session.New(conf)) s := &SQSService{ Svc: svc, Logger: NoopLogger, } var url *string var err error if url, err = SetupQueue(svc, queueName...
[ "func", "SQSServiceForQueue", "(", "queueName", "string", ",", "opts", "...", "AWSConfigOption", ")", "(", "*", "SQSService", ",", "error", ")", "{", "conf", ":=", "&", "aws", ".", "Config", "{", "}", "\n", "for", "_", ",", "o", ":=", "range", "opts", ...
// SQSServiceForQueue creates an AWS SQS client configured for the given region and gets or creates a queue with the given name.
[ "SQSServiceForQueue", "creates", "an", "AWS", "SQS", "client", "configured", "for", "the", "given", "region", "and", "gets", "or", "creates", "a", "queue", "with", "the", "given", "name", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/sqs_service.go#L10-L30
136,917
Wattpad/sqsconsumer
sqs_service.go
SetupQueue
func SetupQueue(svc SQSAPI, name string) (*string, error) { // if the queue already exists just get the url getResp, err := svc.GetQueueUrl(&sqs.GetQueueUrlInput{ QueueName: aws.String(name), }) if err == nil { return getResp.QueueUrl, nil } // fallback to creating the queue createResp, err := svc.CreateQue...
go
func SetupQueue(svc SQSAPI, name string) (*string, error) { // if the queue already exists just get the url getResp, err := svc.GetQueueUrl(&sqs.GetQueueUrlInput{ QueueName: aws.String(name), }) if err == nil { return getResp.QueueUrl, nil } // fallback to creating the queue createResp, err := svc.CreateQue...
[ "func", "SetupQueue", "(", "svc", "SQSAPI", ",", "name", "string", ")", "(", "*", "string", ",", "error", ")", "{", "// if the queue already exists just get the url", "getResp", ",", "err", ":=", "svc", ".", "GetQueueUrl", "(", "&", "sqs", ".", "GetQueueUrlInp...
// SetupQueue creates the queue to listen on and returns the URL.
[ "SetupQueue", "creates", "the", "queue", "to", "listen", "on", "and", "returns", "the", "URL", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/sqs_service.go#L48-L70
136,918
Wattpad/sqsconsumer
middleware/movingaverage/exponential_moving_average.go
New
func New(period time.Duration) *ExponentialMovingAverage { return &ExponentialMovingAverage{ mu: sync.Mutex{}, t: time.Now(), period: period.Seconds(), } }
go
func New(period time.Duration) *ExponentialMovingAverage { return &ExponentialMovingAverage{ mu: sync.Mutex{}, t: time.Now(), period: period.Seconds(), } }
[ "func", "New", "(", "period", "time", ".", "Duration", ")", "*", "ExponentialMovingAverage", "{", "return", "&", "ExponentialMovingAverage", "{", "mu", ":", "sync", ".", "Mutex", "{", "}", ",", "t", ":", "time", ".", "Now", "(", ")", ",", "period", ":"...
// NewExponentialMovingAverage creates an EMA for a given period
[ "NewExponentialMovingAverage", "creates", "an", "EMA", "for", "a", "given", "period" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/movingaverage/exponential_moving_average.go#L18-L24
136,919
Wattpad/sqsconsumer
middleware/movingaverage/exponential_moving_average.go
Update
func (ema *ExponentialMovingAverage) Update(value float64) float64 { now := time.Now() a := 1.0 - math.Exp(ema.t.Sub(now).Seconds()/ema.period) v := a*value + (1.0-a)*ema.v ema.mu.Lock() ema.v = v ema.t = now ema.mu.Unlock() return v }
go
func (ema *ExponentialMovingAverage) Update(value float64) float64 { now := time.Now() a := 1.0 - math.Exp(ema.t.Sub(now).Seconds()/ema.period) v := a*value + (1.0-a)*ema.v ema.mu.Lock() ema.v = v ema.t = now ema.mu.Unlock() return v }
[ "func", "(", "ema", "*", "ExponentialMovingAverage", ")", "Update", "(", "value", "float64", ")", "float64", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "a", ":=", "1.0", "-", "math", ".", "Exp", "(", "ema", ".", "t", ".", "Sub", "(", "...
// Update computes the next value in a moving average
[ "Update", "computes", "the", "next", "value", "in", "a", "moving", "average" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/movingaverage/exponential_moving_average.go#L27-L38
136,920
Wattpad/sqsconsumer
middleware/movingaverage/exponential_moving_average.go
Value
func (ema *ExponentialMovingAverage) Value() float64 { ema.mu.Lock() defer ema.mu.Unlock() return ema.v }
go
func (ema *ExponentialMovingAverage) Value() float64 { ema.mu.Lock() defer ema.mu.Unlock() return ema.v }
[ "func", "(", "ema", "*", "ExponentialMovingAverage", ")", "Value", "(", ")", "float64", "{", "ema", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ema", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "return", "ema", ".", "v", "\n", "}" ]
// Value gets the current average
[ "Value", "gets", "the", "current", "average" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/movingaverage/exponential_moving_average.go#L41-L46
136,921
Wattpad/sqsconsumer
example/main.go
processMessage
func processMessage(ctx context.Context, msg string) error { log.Printf("Starting processMessage for msg %s", msg) // simulate random errors and random delays in message processing r := rand.Intn(10) if r < 3 { return fmt.Errorf("a random error processing msg: %s", msg) // } else if r < 6 { // log.Printf("S...
go
func processMessage(ctx context.Context, msg string) error { log.Printf("Starting processMessage for msg %s", msg) // simulate random errors and random delays in message processing r := rand.Intn(10) if r < 3 { return fmt.Errorf("a random error processing msg: %s", msg) // } else if r < 6 { // log.Printf("S...
[ "func", "processMessage", "(", "ctx", "context", ".", "Context", ",", "msg", "string", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "msg", ")", "\n\n", "// simulate random errors and random delays in message processing", "r", ":=", "rand", ".",...
// processMessage is an example processor function which randomly errors or delays processing and demonstrates using the context.
[ "processMessage", "is", "an", "example", "processor", "function", "which", "randomly", "errors", "or", "delays", "processing", "and", "demonstrates", "using", "the", "context", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/example/main.go#L84-L107
136,922
Wattpad/sqsconsumer
example/main.go
exposeMetrics
func exposeMetrics() { goroutines := expvar.NewInt("total_goroutines") uptime := expvar.NewFloat("process_uptime_seconds") start := time.Now() go func() { for range time.Tick(5 * time.Second) { goroutines.Set(int64(runtime.NumGoroutine())) uptime.Set(time.Since(start).Seconds()) } }() log.Println("Ex...
go
func exposeMetrics() { goroutines := expvar.NewInt("total_goroutines") uptime := expvar.NewFloat("process_uptime_seconds") start := time.Now() go func() { for range time.Tick(5 * time.Second) { goroutines.Set(int64(runtime.NumGoroutine())) uptime.Set(time.Since(start).Seconds()) } }() log.Println("Ex...
[ "func", "exposeMetrics", "(", ")", "{", "goroutines", ":=", "expvar", ".", "NewInt", "(", "\"", "\"", ")", "\n", "uptime", ":=", "expvar", ".", "NewFloat", "(", "\"", "\"", ")", "\n\n", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "go", "fu...
// exposeMetrics adds expvar metrics updated every 5 seconds and runs the HTTP server to expose them.
[ "exposeMetrics", "adds", "expvar", "metrics", "updated", "every", "5", "seconds", "and", "runs", "the", "HTTP", "server", "to", "expose", "them", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/example/main.go#L110-L125
136,923
Wattpad/sqsconsumer
queue_consumer.go
NewConsumer
func NewConsumer(s *SQSService, handler MessageHandlerFunc) *Consumer { return &Consumer{ s: s, handler: handler, delayAfterReceiveError: defaultDelayAfterReceiveError, WaitSeconds: defaultReceiveMessageWaitSeconds, ReceiveVisibil...
go
func NewConsumer(s *SQSService, handler MessageHandlerFunc) *Consumer { return &Consumer{ s: s, handler: handler, delayAfterReceiveError: defaultDelayAfterReceiveError, WaitSeconds: defaultReceiveMessageWaitSeconds, ReceiveVisibil...
[ "func", "NewConsumer", "(", "s", "*", "SQSService", ",", "handler", "MessageHandlerFunc", ")", "*", "Consumer", "{", "return", "&", "Consumer", "{", "s", ":", "s", ",", "handler", ":", "handler", ",", "delayAfterReceiveError", ":", "defaultDelayAfterReceiveError...
// NewConsumer creates a Consumer that uses the given SQSService to connect and invokes the handler for each message received.
[ "NewConsumer", "creates", "a", "Consumer", "that", "uses", "the", "given", "SQSService", "to", "connect", "and", "invokes", "the", "handler", "for", "each", "message", "received", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/queue_consumer.go#L14-L28
136,924
Wattpad/sqsconsumer
queue_consumer.go
SetLogger
func (mf *Consumer) SetLogger(fn func(format string, args ...interface{})) { mf.Logger = fn mf.s.Logger = fn }
go
func (mf *Consumer) SetLogger(fn func(format string, args ...interface{})) { mf.Logger = fn mf.s.Logger = fn }
[ "func", "(", "mf", "*", "Consumer", ")", "SetLogger", "(", "fn", "func", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", ")", "{", "mf", ".", "Logger", "=", "fn", "\n", "mf", ".", "s", ".", "Logger", "=", "fn", "\n", "}...
// SetLogger sets the consumer and service loggers to a function similar to fmt.Printf
[ "SetLogger", "sets", "the", "consumer", "and", "service", "loggers", "to", "a", "function", "similar", "to", "fmt", ".", "Printf" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/queue_consumer.go#L31-L34
136,925
Wattpad/sqsconsumer
queue_consumer.go
Run
func (mf *Consumer) Run(ctx context.Context) error { wg := &sync.WaitGroup{} jobs := make(chan job) mf.startWorkers(ctx, jobs, wg) cleanupWG := &sync.WaitGroup{} cleanupCtx, cleanupCancel := context.WithCancel(context.Background()) del := NewBatchDeleter(cleanupCtx, cleanupWG, mf.s, mf.DeleteMessageAccumulatorTi...
go
func (mf *Consumer) Run(ctx context.Context) error { wg := &sync.WaitGroup{} jobs := make(chan job) mf.startWorkers(ctx, jobs, wg) cleanupWG := &sync.WaitGroup{} cleanupCtx, cleanupCancel := context.WithCancel(context.Background()) del := NewBatchDeleter(cleanupCtx, cleanupWG, mf.s, mf.DeleteMessageAccumulatorTi...
[ "func", "(", "mf", "*", "Consumer", ")", "Run", "(", "ctx", "context", ".", "Context", ")", "error", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "jobs", ":=", "make", "(", "chan", "job", ")", "\n", "mf", ".", "startWorkers", "...
// Run starts the Consumer, gracefully stopping it when the given context is cancelled.
[ "Run", "starts", "the", "Consumer", "gracefully", "stopping", "it", "when", "the", "given", "context", "is", "cancelled", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/queue_consumer.go#L125-L157
136,926
Wattpad/sqsconsumer
middleware/track_consumption_rate.go
TrackConsumptionRate
func TrackConsumptionRate(log Logger, period time.Duration, format string) MessageHandlerDecorator { var count int64 go func() { for { <-time.After(period) c := atomic.SwapInt64(&count, 0) log.Printf(format, c) } }() return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { re...
go
func TrackConsumptionRate(log Logger, period time.Duration, format string) MessageHandlerDecorator { var count int64 go func() { for { <-time.After(period) c := atomic.SwapInt64(&count, 0) log.Printf(format, c) } }() return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { re...
[ "func", "TrackConsumptionRate", "(", "log", "Logger", ",", "period", "time", ".", "Duration", ",", "format", "string", ")", "MessageHandlerDecorator", "{", "var", "count", "int64", "\n\n", "go", "func", "(", ")", "{", "for", "{", "<-", "time", ".", "After"...
// TrackConsumptionRate invokes the logger once per specified period with the format and the int64 number of requests consumed during the period
[ "TrackConsumptionRate", "invokes", "the", "logger", "once", "per", "specified", "period", "with", "the", "format", "and", "the", "int64", "number", "of", "requests", "consumed", "during", "the", "period" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/track_consumption_rate.go#L16-L34
136,927
Wattpad/sqsconsumer
cleanup_visibility.go
NewBatchVisibilityExtender
func NewBatchVisibilityExtender(ctx context.Context, s *SQSService, ticker <-chan time.Time, extensionSecs int64, pending []*sqs.Message) chan<- *sqs.Message { entries := make([]*sqs.Message, len(pending)) copy(entries, pending) veq := &visibilityExtenderQueue{ svc: s, ticker: ticker, extensi...
go
func NewBatchVisibilityExtender(ctx context.Context, s *SQSService, ticker <-chan time.Time, extensionSecs int64, pending []*sqs.Message) chan<- *sqs.Message { entries := make([]*sqs.Message, len(pending)) copy(entries, pending) veq := &visibilityExtenderQueue{ svc: s, ticker: ticker, extensi...
[ "func", "NewBatchVisibilityExtender", "(", "ctx", "context", ".", "Context", ",", "s", "*", "SQSService", ",", "ticker", "<-", "chan", "time", ".", "Time", ",", "extensionSecs", "int64", ",", "pending", "[", "]", "*", "sqs", ".", "Message", ")", "chan", ...
// NewBatchBatchVisibilityExtender starts a batch visibility extender routine that extends visibilty on messages until they are sent to the returned channel
[ "NewBatchBatchVisibilityExtender", "starts", "a", "batch", "visibility", "extender", "routine", "that", "extends", "visibilty", "on", "messages", "until", "they", "are", "sent", "to", "the", "returned", "channel" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_visibility.go#L23-L36
136,928
Wattpad/sqsconsumer
cleanup_visibility.go
extendBatch
func (veq *visibilityExtenderQueue) extendBatch(msgs []*sqs.Message) ([]*sqs.Message, error) { if len(msgs) == 0 { return nil, nil } var entries []*sqs.ChangeMessageVisibilityBatchRequestEntry for _, m := range msgs { veq.svc.Logger("Extending visibility timeout for message %s", aws.StringValue(m.MessageId)) ...
go
func (veq *visibilityExtenderQueue) extendBatch(msgs []*sqs.Message) ([]*sqs.Message, error) { if len(msgs) == 0 { return nil, nil } var entries []*sqs.ChangeMessageVisibilityBatchRequestEntry for _, m := range msgs { veq.svc.Logger("Extending visibility timeout for message %s", aws.StringValue(m.MessageId)) ...
[ "func", "(", "veq", "*", "visibilityExtenderQueue", ")", "extendBatch", "(", "msgs", "[", "]", "*", "sqs", ".", "Message", ")", "(", "[", "]", "*", "sqs", ".", "Message", ",", "error", ")", "{", "if", "len", "(", "msgs", ")", "==", "0", "{", "ret...
// extendBatch extends the visibility of a batch of messages and returns the list of messages that failed to extend and an error for overall failure.
[ "extendBatch", "extends", "the", "visibility", "of", "a", "batch", "of", "messages", "and", "returns", "the", "list", "of", "messages", "that", "failed", "to", "extend", "and", "an", "error", "for", "overall", "failure", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_visibility.go#L51-L85
136,929
Wattpad/sqsconsumer
cleanup_visibility.go
extendPending
func (veq *visibilityExtenderQueue) extendPending() { veq.Lock() defer veq.Unlock() fails, err := veq.extendBatch(veq.entries) if err != nil { veq.svc.Logger("Error extending batch: %s", err) } var retries uint for len(fails) > 0 && retries <= 5 { retries++ time.Sleep(time.Duration((2<<retries)*50) * tim...
go
func (veq *visibilityExtenderQueue) extendPending() { veq.Lock() defer veq.Unlock() fails, err := veq.extendBatch(veq.entries) if err != nil { veq.svc.Logger("Error extending batch: %s", err) } var retries uint for len(fails) > 0 && retries <= 5 { retries++ time.Sleep(time.Duration((2<<retries)*50) * tim...
[ "func", "(", "veq", "*", "visibilityExtenderQueue", ")", "extendPending", "(", ")", "{", "veq", ".", "Lock", "(", ")", "\n", "defer", "veq", ".", "Unlock", "(", ")", "\n\n", "fails", ",", "err", ":=", "veq", ".", "extendBatch", "(", "veq", ".", "entr...
// extendPending extends all the pending messages
[ "extendPending", "extends", "all", "the", "pending", "messages" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/cleanup_visibility.go#L88-L106
136,930
Wattpad/sqsconsumer
middleware/track_message_age.go
TrackMessageAge
func TrackMessageAge(period time.Duration, f func(age float64)) MessageHandlerDecorator { ema := movingaverage.New(period) go func() { for { <-time.After(period) f(ema.Value()) } }() return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { return func(ctx context.Context, msg st...
go
func TrackMessageAge(period time.Duration, f func(age float64)) MessageHandlerDecorator { ema := movingaverage.New(period) go func() { for { <-time.After(period) f(ema.Value()) } }() return func(fn sqsconsumer.MessageHandlerFunc) sqsconsumer.MessageHandlerFunc { return func(ctx context.Context, msg st...
[ "func", "TrackMessageAge", "(", "period", "time", ".", "Duration", ",", "f", "func", "(", "age", "float64", ")", ")", "MessageHandlerDecorator", "{", "ema", ":=", "movingaverage", ".", "New", "(", "period", ")", "\n\n", "go", "func", "(", ")", "{", "for"...
// TrackMessageAge is middleware that tracks the exponential moving average of message age, calling a callback function with the current average periodically
[ "TrackMessageAge", "is", "middleware", "that", "tracks", "the", "exponential", "moving", "average", "of", "message", "age", "calling", "a", "callback", "function", "with", "the", "current", "average", "periodically" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/track_message_age.go#L15-L35
136,931
Wattpad/sqsconsumer
middleware/track_message_age.go
computeMessageAge
func computeMessageAge(ctx context.Context) (float64, error) { m, ok := sqsmessage.FromContext(ctx) if !ok { return 0, errCannotComputeAge } // only count the first receipt receiveCount, ok := m.Attributes["ApproximateReceiveCount"] if !ok { return 0, errCannotComputeAge } rc, err := strconv.ParseInt(*rec...
go
func computeMessageAge(ctx context.Context) (float64, error) { m, ok := sqsmessage.FromContext(ctx) if !ok { return 0, errCannotComputeAge } // only count the first receipt receiveCount, ok := m.Attributes["ApproximateReceiveCount"] if !ok { return 0, errCannotComputeAge } rc, err := strconv.ParseInt(*rec...
[ "func", "computeMessageAge", "(", "ctx", "context", ".", "Context", ")", "(", "float64", ",", "error", ")", "{", "m", ",", "ok", ":=", "sqsmessage", ".", "FromContext", "(", "ctx", ")", "\n", "if", "!", "ok", "{", "return", "0", ",", "errCannotComputeA...
// computeMessageAge computes the age in seconds of a message
[ "computeMessageAge", "computes", "the", "age", "in", "seconds", "of", "a", "message" ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/middleware/track_message_age.go#L45-L79
136,932
Wattpad/sqsconsumer
sqsmessage/sqs_message_context.go
NewContext
func NewContext(ctx context.Context, msg *sqs.Message) context.Context { return context.WithValue(ctx, sqsMessageKey, msg) }
go
func NewContext(ctx context.Context, msg *sqs.Message) context.Context { return context.WithValue(ctx, sqsMessageKey, msg) }
[ "func", "NewContext", "(", "ctx", "context", ".", "Context", ",", "msg", "*", "sqs", ".", "Message", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "sqsMessageKey", ",", "msg", ")", "\n", "}" ]
// NewContext returns a new Context carrying msg.
[ "NewContext", "returns", "a", "new", "Context", "carrying", "msg", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/sqsmessage/sqs_message_context.go#L15-L17
136,933
Wattpad/sqsconsumer
sqsmessage/sqs_message_context.go
FromContext
func FromContext(ctx context.Context) (*sqs.Message, bool) { msg, ok := ctx.Value(sqsMessageKey).(*sqs.Message) return msg, ok }
go
func FromContext(ctx context.Context) (*sqs.Message, bool) { msg, ok := ctx.Value(sqsMessageKey).(*sqs.Message) return msg, ok }
[ "func", "FromContext", "(", "ctx", "context", ".", "Context", ")", "(", "*", "sqs", ".", "Message", ",", "bool", ")", "{", "msg", ",", "ok", ":=", "ctx", ".", "Value", "(", "sqsMessageKey", ")", ".", "(", "*", "sqs", ".", "Message", ")", "\n", "r...
// FromContext extracts the SQS message from ctx, if present.
[ "FromContext", "extracts", "the", "SQS", "message", "from", "ctx", "if", "present", "." ]
fa099c630d1bf760383ee3147fe75ae2fe6f0912
https://github.com/Wattpad/sqsconsumer/blob/fa099c630d1bf760383ee3147fe75ae2fe6f0912/sqsmessage/sqs_message_context.go#L20-L23
136,934
StephanDollberg/go-json-rest-middleware-jwt
auth_jwt.go
MiddlewareFunc
func (mw *JWTMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc { if mw.Realm == "" { log.Fatal("Realm is required") } if mw.SigningAlgorithm == "" { mw.SigningAlgorithm = "HS256" } if mw.Key == nil { log.Fatal("Key required") } if mw.Timeout == 0 { mw.Timeout = time.Hour } if mw.Au...
go
func (mw *JWTMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc { if mw.Realm == "" { log.Fatal("Realm is required") } if mw.SigningAlgorithm == "" { mw.SigningAlgorithm = "HS256" } if mw.Key == nil { log.Fatal("Key required") } if mw.Timeout == 0 { mw.Timeout = time.Hour } if mw.Au...
[ "func", "(", "mw", "*", "JWTMiddleware", ")", "MiddlewareFunc", "(", "handler", "rest", ".", "HandlerFunc", ")", "rest", ".", "HandlerFunc", "{", "if", "mw", ".", "Realm", "==", "\"", "\"", "{", "log", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", ...
// MiddlewareFunc makes JWTMiddleware implement the Middleware interface.
[ "MiddlewareFunc", "makes", "JWTMiddleware", "implement", "the", "Middleware", "interface", "." ]
be2a0500d9b32741c6823e55c27b4a79151272eb
https://github.com/StephanDollberg/go-json-rest-middleware-jwt/blob/be2a0500d9b32741c6823e55c27b4a79151272eb/auth_jwt.go#L59-L83
136,935
StephanDollberg/go-json-rest-middleware-jwt
auth_jwt.go
ExtractClaims
func ExtractClaims(request *rest.Request) map[string]interface{} { if request.Env["JWT_PAYLOAD"] == nil { emptyClaims := make(map[string]interface{}) return emptyClaims } jwtClaims := request.Env["JWT_PAYLOAD"].(map[string]interface{}) return jwtClaims }
go
func ExtractClaims(request *rest.Request) map[string]interface{} { if request.Env["JWT_PAYLOAD"] == nil { emptyClaims := make(map[string]interface{}) return emptyClaims } jwtClaims := request.Env["JWT_PAYLOAD"].(map[string]interface{}) return jwtClaims }
[ "func", "ExtractClaims", "(", "request", "*", "rest", ".", "Request", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "if", "request", ".", "Env", "[", "\"", "\"", "]", "==", "nil", "{", "emptyClaims", ":=", "make", "(", "map", "[", "st...
// ExtractClaims allows to retrieve the payload
[ "ExtractClaims", "allows", "to", "retrieve", "the", "payload" ]
be2a0500d9b32741c6823e55c27b4a79151272eb
https://github.com/StephanDollberg/go-json-rest-middleware-jwt/blob/be2a0500d9b32741c6823e55c27b4a79151272eb/auth_jwt.go#L114-L121
136,936
elodina/go_kafka_client
topics.go
GetTopicsToNumStreamsMap
func (tc *WildcardTopicsToNumStreams) GetTopicsToNumStreamsMap() map[string]int { result := make(map[string]int) result[tc.TopicFilter.Regex()] = tc.NumStreams return result }
go
func (tc *WildcardTopicsToNumStreams) GetTopicsToNumStreamsMap() map[string]int { result := make(map[string]int) result[tc.TopicFilter.Regex()] = tc.NumStreams return result }
[ "func", "(", "tc", "*", "WildcardTopicsToNumStreams", ")", "GetTopicsToNumStreamsMap", "(", ")", "map", "[", "string", "]", "int", "{", "result", ":=", "make", "(", "map", "[", "string", "]", "int", ")", "\n", "result", "[", "tc", ".", "TopicFilter", "."...
//Creates a map descibing consumer subscription where keys are topic names and values are number of fetchers used to fetch these topics.
[ "Creates", "a", "map", "descibing", "consumer", "subscription", "where", "keys", "are", "topic", "names", "and", "values", "are", "number", "of", "fetchers", "used", "to", "fetch", "these", "topics", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/topics.go#L187-L191
136,937
elodina/go_kafka_client
topics.go
Pattern
func (tc *WildcardTopicsToNumStreams) Pattern() string { switch tc.TopicFilter.(type) { case *WhiteList: return whiteListPattern case *BlackList: return blackListPattern default: panic("unknown topic filter") } }
go
func (tc *WildcardTopicsToNumStreams) Pattern() string { switch tc.TopicFilter.(type) { case *WhiteList: return whiteListPattern case *BlackList: return blackListPattern default: panic("unknown topic filter") } }
[ "func", "(", "tc", "*", "WildcardTopicsToNumStreams", ")", "Pattern", "(", ")", "string", "{", "switch", "tc", ".", "TopicFilter", ".", "(", "type", ")", "{", "case", "*", "WhiteList", ":", "return", "whiteListPattern", "\n", "case", "*", "BlackList", ":",...
//Returns a pattern describing this TopicsToNumStreams.
[ "Returns", "a", "pattern", "describing", "this", "TopicsToNumStreams", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/topics.go#L194-L203
136,938
elodina/go_kafka_client
consumer.go
maintainCleanCoordinator
func (c *Consumer) maintainCleanCoordinator() { if c.stopCleanup != nil { return } c.stopCleanup = make(chan struct{}) go func() { tick := time.NewTicker(5 * time.Minute) defer tick.Stop() for { select { case <-tick.C: Infof(c, "Starting coordinator cleanup of API requests for %s", c.config.Group...
go
func (c *Consumer) maintainCleanCoordinator() { if c.stopCleanup != nil { return } c.stopCleanup = make(chan struct{}) go func() { tick := time.NewTicker(5 * time.Minute) defer tick.Stop() for { select { case <-tick.C: Infof(c, "Starting coordinator cleanup of API requests for %s", c.config.Group...
[ "func", "(", "c", "*", "Consumer", ")", "maintainCleanCoordinator", "(", ")", "{", "if", "c", ".", "stopCleanup", "!=", "nil", "{", "return", "\n", "}", "\n\n", "c", ".", "stopCleanup", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", ...
// maintainCleanCoordinator runs on an interval to make sure that the coordinator removes old API requests to remove bloat from the coordinator over time.
[ "maintainCleanCoordinator", "runs", "on", "an", "interval", "to", "make", "sure", "that", "the", "coordinator", "removes", "old", "API", "requests", "to", "remove", "bloat", "from", "the", "coordinator", "over", "time", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/consumer.go#L217-L236
136,939
elodina/go_kafka_client
consumer.go
Close
func (c *Consumer) Close() <-chan bool { Info(c, "Consumer closing started...") c.isShuttingdown = true go func() { select { case c.close <- true: default: } Info(c, "Unsubscribing...") if c.shouldUnsubscribe { c.unsubscribeFromChanges() } Info(c, "Closing fetcher manager...") <-c.fetcher.clos...
go
func (c *Consumer) Close() <-chan bool { Info(c, "Consumer closing started...") c.isShuttingdown = true go func() { select { case c.close <- true: default: } Info(c, "Unsubscribing...") if c.shouldUnsubscribe { c.unsubscribeFromChanges() } Info(c, "Closing fetcher manager...") <-c.fetcher.clos...
[ "func", "(", "c", "*", "Consumer", ")", "Close", "(", ")", "<-", "chan", "bool", "{", "Info", "(", "c", ",", "\"", "\"", ")", "\n", "c", ".", "isShuttingdown", "=", "true", "\n", "go", "func", "(", ")", "{", "select", "{", "case", "c", ".", "...
// Tells the Consumer to close all existing connections and stop. // This method is NOT blocking but returns a channel which will get a single value once the closing is finished.
[ "Tells", "the", "Consumer", "to", "close", "all", "existing", "connections", "and", "stop", ".", "This", "method", "is", "NOT", "blocking", "but", "returns", "a", "channel", "which", "will", "get", "a", "single", "value", "once", "the", "closing", "is", "f...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/consumer.go#L326-L372
136,940
elodina/go_kafka_client
consumer.go
StateSnapshot
func (c *Consumer) StateSnapshot() *StateSnapshot { metricsMap := c.metrics.Stats() offsetsMap := make(map[string]map[int32]int64) for topicAndPartition, workerManager := range c.workerManagers { if _, exists := offsetsMap[topicAndPartition.Topic]; !exists { offsetsMap[topicAndPartition.Topic] = make(map[int32...
go
func (c *Consumer) StateSnapshot() *StateSnapshot { metricsMap := c.metrics.Stats() offsetsMap := make(map[string]map[int32]int64) for topicAndPartition, workerManager := range c.workerManagers { if _, exists := offsetsMap[topicAndPartition.Topic]; !exists { offsetsMap[topicAndPartition.Topic] = make(map[int32...
[ "func", "(", "c", "*", "Consumer", ")", "StateSnapshot", "(", ")", "*", "StateSnapshot", "{", "metricsMap", ":=", "c", ".", "metrics", ".", "Stats", "(", ")", "\n\n", "offsetsMap", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "int32", "]...
// Returns a state snapshot for this consumer. State snapshot contains a set of metrics splitted by topics and partitions.
[ "Returns", "a", "state", "snapshot", "for", "this", "consumer", ".", "State", "snapshot", "contains", "a", "set", "of", "metrics", "splitted", "by", "topics", "and", "partitions", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/consumer.go#L941-L957
136,941
elodina/go_kafka_client
workers.go
NewWorkerManager
func NewWorkerManager(id string, config *ConsumerConfig, topicPartition TopicAndPartition, metrics *ConsumerMetrics, closeConsumer chan bool) *WorkerManager { workers := make([]*Worker, config.NumWorkers) availableWorkers := make(chan *Worker, config.NumWorkers) for i := 0; i < config.NumWorkers; i++ { workers[i] ...
go
func NewWorkerManager(id string, config *ConsumerConfig, topicPartition TopicAndPartition, metrics *ConsumerMetrics, closeConsumer chan bool) *WorkerManager { workers := make([]*Worker, config.NumWorkers) availableWorkers := make(chan *Worker, config.NumWorkers) for i := 0; i < config.NumWorkers; i++ { workers[i] ...
[ "func", "NewWorkerManager", "(", "id", "string", ",", "config", "*", "ConsumerConfig", ",", "topicPartition", "TopicAndPartition", ",", "metrics", "*", "ConsumerMetrics", ",", "closeConsumer", "chan", "bool", ")", "*", "WorkerManager", "{", "workers", ":=", "make"...
// Creates a new WorkerManager with given id using a given ConsumerConfig and responsible for managing given TopicAndPartition.
[ "Creates", "a", "new", "WorkerManager", "with", "given", "id", "using", "a", "given", "ConsumerConfig", "and", "responsible", "for", "managing", "given", "TopicAndPartition", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L52-L86
136,942
elodina/go_kafka_client
workers.go
Start
func (wm *WorkerManager) Start() { go wm.processBatch() go wm.commitBatch() for { startIdle := time.Now() // force manager stop to be checked first select { case <-wm.managerStop: return default: select { case batch := <-wm.inputChannel: { wm.metrics.wMsIdle().Update(time.Since(startIdle)...
go
func (wm *WorkerManager) Start() { go wm.processBatch() go wm.commitBatch() for { startIdle := time.Now() // force manager stop to be checked first select { case <-wm.managerStop: return default: select { case batch := <-wm.inputChannel: { wm.metrics.wMsIdle().Update(time.Since(startIdle)...
[ "func", "(", "wm", "*", "WorkerManager", ")", "Start", "(", ")", "{", "go", "wm", ".", "processBatch", "(", ")", "\n", "go", "wm", ".", "commitBatch", "(", ")", "\n", "for", "{", "startIdle", ":=", "time", ".", "Now", "(", ")", "\n", "// force mana...
// Starts processing incoming batches with this WorkerManager. Processing is possible only in batch-at-once mode. // It also launches an offset committer routine. // Call to this method blocks.
[ "Starts", "processing", "incoming", "batches", "with", "this", "WorkerManager", ".", "Processing", "is", "possible", "only", "in", "batch", "-", "at", "-", "once", "mode", ".", "It", "also", "launches", "an", "offset", "committer", "routine", ".", "Call", "t...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L95-L124
136,943
elodina/go_kafka_client
workers.go
Stop
func (wm *WorkerManager) Stop() chan bool { finished := make(chan bool) go func() { Debugf(wm, "Trying to stop workerManager") inLock(&wm.stopLock, func() { Debug(wm, "Stopping manager") wm.managerStop <- true Debug(wm, "Stopping processor") wm.processingStop <- true Debug(wm, "Successful manager s...
go
func (wm *WorkerManager) Stop() chan bool { finished := make(chan bool) go func() { Debugf(wm, "Trying to stop workerManager") inLock(&wm.stopLock, func() { Debug(wm, "Stopping manager") wm.managerStop <- true Debug(wm, "Stopping processor") wm.processingStop <- true Debug(wm, "Successful manager s...
[ "func", "(", "wm", "*", "WorkerManager", ")", "Stop", "(", ")", "chan", "bool", "{", "finished", ":=", "make", "(", "chan", "bool", ")", "\n", "go", "func", "(", ")", "{", "Debugf", "(", "wm", ",", "\"", "\"", ")", "\n", "inLock", "(", "&", "wm...
// Tells this WorkerManager to finish processing current batch, stop accepting new work and shut down. // This method returns immediately and returns a channel which will get the value once the shut down is finished.
[ "Tells", "this", "WorkerManager", "to", "finish", "processing", "current", "batch", "stop", "accepting", "new", "work", "and", "shut", "down", ".", "This", "method", "returns", "immediately", "and", "returns", "a", "channel", "which", "will", "get", "the", "va...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L128-L156
136,944
elodina/go_kafka_client
workers.go
UpdateLargestOffset
func (wm *WorkerManager) UpdateLargestOffset(offset int64) { atomic.StoreInt64(&wm.largestOffset, int64(math.Max(float64(wm.GetLargestOffset()), float64(offset)))) }
go
func (wm *WorkerManager) UpdateLargestOffset(offset int64) { atomic.StoreInt64(&wm.largestOffset, int64(math.Max(float64(wm.GetLargestOffset()), float64(offset)))) }
[ "func", "(", "wm", "*", "WorkerManager", ")", "UpdateLargestOffset", "(", "offset", "int64", ")", "{", "atomic", ".", "StoreInt64", "(", "&", "wm", ".", "largestOffset", ",", "int64", "(", "math", ".", "Max", "(", "float64", "(", "wm", ".", "GetLargestOf...
// Updates the highest offset that has been processed by this WorkerManager with a new value.
[ "Updates", "the", "highest", "offset", "that", "has", "been", "processed", "by", "this", "WorkerManager", "with", "a", "new", "value", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L369-L371
136,945
elodina/go_kafka_client
workers.go
Start
func (w *Worker) Start() { handlerInterrupted := false go func() { for taskAndStrategy := range w.HandlerInputChannel { result := taskAndStrategy.Strategy(w, taskAndStrategy.WorkerTask.Msg, taskAndStrategy.WorkerTask.Id()) Loop: for !handlerInterrupted { timeout := time.NewTimer(5 * time.Second) sel...
go
func (w *Worker) Start() { handlerInterrupted := false go func() { for taskAndStrategy := range w.HandlerInputChannel { result := taskAndStrategy.Strategy(w, taskAndStrategy.WorkerTask.Msg, taskAndStrategy.WorkerTask.Id()) Loop: for !handlerInterrupted { timeout := time.NewTimer(5 * time.Second) sel...
[ "func", "(", "w", "*", "Worker", ")", "Start", "(", ")", "{", "handlerInterrupted", ":=", "false", "\n", "go", "func", "(", ")", "{", "for", "taskAndStrategy", ":=", "range", "w", ".", "HandlerInputChannel", "{", "result", ":=", "taskAndStrategy", ".", "...
// Starts processing a given task using given strategy with this worker. // Call to this method blocks until the task is done or timed out.
[ "Starts", "processing", "a", "given", "task", "using", "given", "strategy", "with", "this", "worker", ".", "Call", "to", "this", "method", "blocks", "until", "the", "task", "is", "done", "or", "timed", "out", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L400-L438
136,946
elodina/go_kafka_client
workers.go
NewFailureCounter
func NewFailureCounter(FailedThreshold int32, WorkerThresholdTimeWindow time.Duration) *FailureCounter { counter := &FailureCounter{ failedThreshold: FailedThreshold, stop: make(chan bool), } go func() { for { timeout := time.NewTimer(WorkerThresholdTimeWindow) select { case <-timeout.C: ...
go
func NewFailureCounter(FailedThreshold int32, WorkerThresholdTimeWindow time.Duration) *FailureCounter { counter := &FailureCounter{ failedThreshold: FailedThreshold, stop: make(chan bool), } go func() { for { timeout := time.NewTimer(WorkerThresholdTimeWindow) select { case <-timeout.C: ...
[ "func", "NewFailureCounter", "(", "FailedThreshold", "int32", ",", "WorkerThresholdTimeWindow", "time", ".", "Duration", ")", "*", "FailureCounter", "{", "counter", ":=", "&", "FailureCounter", "{", "failedThreshold", ":", "FailedThreshold", ",", "stop", ":", "make"...
// Creates a new FailureCounter with threshold FailedThreshold and time window WorkerThresholdTimeWindow.
[ "Creates", "a", "new", "FailureCounter", "with", "threshold", "FailedThreshold", "and", "time", "window", "WorkerThresholdTimeWindow", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L464-L491
136,947
elodina/go_kafka_client
workers.go
Failed
func (f *FailureCounter) Failed() bool { inLock(&f.countLock, func() { f.count++ }) return f.count >= f.failedThreshold || f.failed }
go
func (f *FailureCounter) Failed() bool { inLock(&f.countLock, func() { f.count++ }) return f.count >= f.failedThreshold || f.failed }
[ "func", "(", "f", "*", "FailureCounter", ")", "Failed", "(", ")", "bool", "{", "inLock", "(", "&", "f", ".", "countLock", ",", "func", "(", ")", "{", "f", ".", "count", "++", "}", ")", "\n", "return", "f", ".", "count", ">=", "f", ".", "failedT...
// Tells this FailureCounter to increment a number of failures by one. // Returns true if threshold is reached, false otherwise.
[ "Tells", "this", "FailureCounter", "to", "increment", "a", "number", "of", "failures", "by", "one", ".", "Returns", "true", "if", "threshold", "is", "reached", "false", "otherwise", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L495-L498
136,948
elodina/go_kafka_client
workers.go
Id
func (t *Task) Id() TaskId { return TaskId{TopicAndPartition{t.Msg.Topic, t.Msg.Partition}, t.Msg.Offset} }
go
func (t *Task) Id() TaskId { return TaskId{TopicAndPartition{t.Msg.Topic, t.Msg.Partition}, t.Msg.Offset} }
[ "func", "(", "t", "*", "Task", ")", "Id", "(", ")", "TaskId", "{", "return", "TaskId", "{", "TopicAndPartition", "{", "t", ".", "Msg", ".", "Topic", ",", "t", ".", "Msg", ".", "Partition", "}", ",", "t", ".", "Msg", ".", "Offset", "}", "\n", "}...
// Returns an id for this Task.
[ "Returns", "an", "id", "for", "this", "Task", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/workers.go#L518-L520
136,949
elodina/go_kafka_client
consumer_config.go
Validate
func (c *ConsumerConfig) Validate() error { if c.Groupid == "" { return errors.New("Groupid cannot be empty") } if c.Consumerid == "" { c.Consumerid = uuid() } if c.NumConsumerFetchers <= 0 { return errors.New("NumConsumerFetchers should be at least 1") } if c.QueuedMaxMessages < 0 { return errors.New...
go
func (c *ConsumerConfig) Validate() error { if c.Groupid == "" { return errors.New("Groupid cannot be empty") } if c.Consumerid == "" { c.Consumerid = uuid() } if c.NumConsumerFetchers <= 0 { return errors.New("NumConsumerFetchers should be at least 1") } if c.QueuedMaxMessages < 0 { return errors.New...
[ "func", "(", "c", "*", "ConsumerConfig", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Groupid", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "c", ".", "Consumerid", "==", "\"",...
// Validate this ConsumerConfig. Returns a corresponding error if the ConsumerConfig is invalid and nil otherwise.
[ "Validate", "this", "ConsumerConfig", ".", "Returns", "a", "corresponding", "error", "if", "the", "ConsumerConfig", "is", "invalid", "and", "nil", "otherwise", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/consumer_config.go#L275-L378
136,950
elodina/go_kafka_client
low_level_client.go
Initialize
func (this *SiestaClient) Initialize() error { bootstrapBrokers, err := BootstrapBrokers(this.config.Coordinator) if err != nil { return err } connectorConfig := siesta.NewConnectorConfig() connectorConfig.BrokerList = bootstrapBrokers connectorConfig.ReadTimeout = this.config.SocketTimeout connectorConfig.Wr...
go
func (this *SiestaClient) Initialize() error { bootstrapBrokers, err := BootstrapBrokers(this.config.Coordinator) if err != nil { return err } connectorConfig := siesta.NewConnectorConfig() connectorConfig.BrokerList = bootstrapBrokers connectorConfig.ReadTimeout = this.config.SocketTimeout connectorConfig.Wr...
[ "func", "(", "this", "*", "SiestaClient", ")", "Initialize", "(", ")", "error", "{", "bootstrapBrokers", ",", "err", ":=", "BootstrapBrokers", "(", "this", ".", "config", ".", "Coordinator", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n"...
// This will be called right after connecting to ConsumerCoordinator so this client can initialize itself // with bootstrap broker list for example. May return an error to signal this client is unable to work with given configuration.
[ "This", "will", "be", "called", "right", "after", "connecting", "to", "ConsumerCoordinator", "so", "this", "client", "can", "initialize", "itself", "with", "bootstrap", "broker", "list", "for", "example", ".", "May", "return", "an", "error", "to", "signal", "t...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L78-L98
136,951
elodina/go_kafka_client
low_level_client.go
Fetch
func (this *SiestaClient) Fetch(topic string, partition int32, offset int64) ([]*Message, error) { Tracef(this, "Fetching %s %d from %d", topic, partition, offset) response, err := this.connector.Fetch(topic, partition, offset) if err != nil { return nil, err } messages := make([]*Message, 0) timestamp := tim...
go
func (this *SiestaClient) Fetch(topic string, partition int32, offset int64) ([]*Message, error) { Tracef(this, "Fetching %s %d from %d", topic, partition, offset) response, err := this.connector.Fetch(topic, partition, offset) if err != nil { return nil, err } messages := make([]*Message, 0) timestamp := tim...
[ "func", "(", "this", "*", "SiestaClient", ")", "Fetch", "(", "topic", "string", ",", "partition", "int32", ",", "offset", "int64", ")", "(", "[", "]", "*", "Message", ",", "error", ")", "{", "Tracef", "(", "this", ",", "\"", "\"", ",", "topic", ","...
// This will be called each time the fetch request to Kafka should be issued. Topic, partition and offset are self-explanatory. // Returns slice of Messages and an error if a fetch error occurred.
[ "This", "will", "be", "called", "each", "time", "the", "fetch", "request", "to", "Kafka", "should", "be", "issued", ".", "Topic", "partition", "and", "offset", "are", "self", "-", "explanatory", ".", "Returns", "slice", "of", "Messages", "and", "an", "erro...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L102-L144
136,952
elodina/go_kafka_client
low_level_client.go
GetErrorType
func (this *SiestaClient) GetErrorType(err error) ErrorType { switch { case err == siesta.ErrOffsetOutOfRange: return ErrorTypeOffsetOutOfRange case err == siesta.ErrEOF: return ErrorTypeCorruptedResponse default: return ErrorTypeOther } }
go
func (this *SiestaClient) GetErrorType(err error) ErrorType { switch { case err == siesta.ErrOffsetOutOfRange: return ErrorTypeOffsetOutOfRange case err == siesta.ErrEOF: return ErrorTypeCorruptedResponse default: return ErrorTypeOther } }
[ "func", "(", "this", "*", "SiestaClient", ")", "GetErrorType", "(", "err", "error", ")", "ErrorType", "{", "switch", "{", "case", "err", "==", "siesta", ".", "ErrOffsetOutOfRange", ":", "return", "ErrorTypeOffsetOutOfRange", "\n", "case", "err", "==", "siesta"...
// Tells the caller what kind of error it is.
[ "Tells", "the", "caller", "what", "kind", "of", "error", "it", "is", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L147-L156
136,953
elodina/go_kafka_client
low_level_client.go
GetAvailableOffset
func (this *SiestaClient) GetAvailableOffset(topic string, partition int32, offsetTime string) (int64, error) { time := siesta.LatestTime if offsetTime == "smallest" { time = siesta.EarliestTime } return this.connector.GetAvailableOffset(topic, partition, time) }
go
func (this *SiestaClient) GetAvailableOffset(topic string, partition int32, offsetTime string) (int64, error) { time := siesta.LatestTime if offsetTime == "smallest" { time = siesta.EarliestTime } return this.connector.GetAvailableOffset(topic, partition, time) }
[ "func", "(", "this", "*", "SiestaClient", ")", "GetAvailableOffset", "(", "topic", "string", ",", "partition", "int32", ",", "offsetTime", "string", ")", "(", "int64", ",", "error", ")", "{", "time", ":=", "siesta", ".", "LatestTime", "\n", "if", "offsetTi...
// This will be called to handle OffsetOutOfRange error. OffsetTime will be either "smallest" or "largest".
[ "This", "will", "be", "called", "to", "handle", "OffsetOutOfRange", "error", ".", "OffsetTime", "will", "be", "either", "smallest", "or", "largest", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L159-L165
136,954
elodina/go_kafka_client
low_level_client.go
GetOffset
func (this *SiestaClient) GetOffset(group string, topic string, partition int32) (int64, error) { offset, err := this.connector.GetOffset(group, topic, partition) if err == siesta.ErrUnknownTopicOrPartition { return -1, nil } return offset, err }
go
func (this *SiestaClient) GetOffset(group string, topic string, partition int32) (int64, error) { offset, err := this.connector.GetOffset(group, topic, partition) if err == siesta.ErrUnknownTopicOrPartition { return -1, nil } return offset, err }
[ "func", "(", "this", "*", "SiestaClient", ")", "GetOffset", "(", "group", "string", ",", "topic", "string", ",", "partition", "int32", ")", "(", "int64", ",", "error", ")", "{", "offset", ",", "err", ":=", "this", ".", "connector", ".", "GetOffset", "(...
// Gets the offset for a given group, topic and partition. // May return an error if fails to retrieve the offset.
[ "Gets", "the", "offset", "for", "a", "given", "group", "topic", "and", "partition", ".", "May", "return", "an", "error", "if", "fails", "to", "retrieve", "the", "offset", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L169-L175
136,955
elodina/go_kafka_client
low_level_client.go
CommitOffset
func (this *SiestaClient) CommitOffset(group string, topic string, partition int32, offset int64) error { return this.connector.CommitOffset(group, topic, partition, offset) }
go
func (this *SiestaClient) CommitOffset(group string, topic string, partition int32, offset int64) error { return this.connector.CommitOffset(group, topic, partition, offset) }
[ "func", "(", "this", "*", "SiestaClient", ")", "CommitOffset", "(", "group", "string", ",", "topic", "string", ",", "partition", "int32", ",", "offset", "int64", ")", "error", "{", "return", "this", ".", "connector", ".", "CommitOffset", "(", "group", ",",...
// Commits the given offset for a given group, topic and partition. // May return an error if fails to commit the offset.
[ "Commits", "the", "given", "offset", "for", "a", "given", "group", "topic", "and", "partition", ".", "May", "return", "an", "error", "if", "fails", "to", "commit", "the", "offset", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L179-L181
136,956
elodina/go_kafka_client
low_level_client.go
BootstrapBrokers
func BootstrapBrokers(coordinator ConsumerCoordinator) ([]string, error) { bootstrapBrokers := make([]string, 0) brokers, err := coordinator.GetAllBrokers() if err != nil { return nil, err } for _, broker := range brokers { bootstrapBrokers = append(bootstrapBrokers, fmt.Sprintf("%s:%d", broker.Host, broker.Po...
go
func BootstrapBrokers(coordinator ConsumerCoordinator) ([]string, error) { bootstrapBrokers := make([]string, 0) brokers, err := coordinator.GetAllBrokers() if err != nil { return nil, err } for _, broker := range brokers { bootstrapBrokers = append(bootstrapBrokers, fmt.Sprintf("%s:%d", broker.Host, broker.Po...
[ "func", "BootstrapBrokers", "(", "coordinator", "ConsumerCoordinator", ")", "(", "[", "]", "string", ",", "error", ")", "{", "bootstrapBrokers", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "brokers", ",", "err", ":=", "coordinator", ".", ...
// BootstrapBrokers queries the ConsumerCoordinator for all known brokers in the cluster to be used later as a bootstrap list for the LowLevelClient.
[ "BootstrapBrokers", "queries", "the", "ConsumerCoordinator", "for", "all", "known", "brokers", "in", "the", "cluster", "to", "be", "used", "later", "as", "a", "bootstrap", "list", "for", "the", "LowLevelClient", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/low_level_client.go#L189-L200
136,957
elodina/go_kafka_client
logger.go
Trace
func Trace(tag interface{}, message interface{}) { Logger.Trace(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), TraceLogTypeId, fmt.Sprintf("%s", message), nil)) }
go
func Trace(tag interface{}, message interface{}) { Logger.Trace(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), TraceLogTypeId, fmt.Sprintf("%s", message), nil)) }
[ "func", "Trace", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ")", "{", "Logger", ".", "Trace", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ")", ")", "\n", "EmitterLogs", ".", "Emit", "(", ...
//Writes a given message with a given tag to log with level Trace.
[ "Writes", "a", "given", "message", "with", "a", "given", "tag", "to", "log", "with", "level", "Trace", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L87-L90
136,958
elodina/go_kafka_client
logger.go
Debugf
func Debugf(tag interface{}, message interface{}, params ...interface{}) { Logger.Debug(fmt.Sprintf("[%s] %s", tag, message), params...) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), DebugLogTypeId, fmt.Sprintf(fmt.Sprintf("%s", message), params...), nil)) }
go
func Debugf(tag interface{}, message interface{}, params ...interface{}) { Logger.Debug(fmt.Sprintf("[%s] %s", tag, message), params...) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), DebugLogTypeId, fmt.Sprintf(fmt.Sprintf("%s", message), params...), nil)) }
[ "func", "Debugf", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ",", "params", "...", "interface", "{", "}", ")", "{", "Logger", ".", "Debug", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ")",...
//Formats a given message according to given params with a given tag to log with level Debug.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "with", "a", "given", "tag", "to", "log", "with", "level", "Debug", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L105-L108
136,959
elodina/go_kafka_client
logger.go
Info
func Info(tag interface{}, message interface{}) { Logger.Info(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), InfoLogTypeId, fmt.Sprintf("%s", message), nil)) }
go
func Info(tag interface{}, message interface{}) { Logger.Info(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), InfoLogTypeId, fmt.Sprintf("%s", message), nil)) }
[ "func", "Info", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ")", "{", "Logger", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ")", ")", "\n", "EmitterLogs", ".", "Emit", "(", "...
//Writes a given message with a given tag to log with level Info.
[ "Writes", "a", "given", "message", "with", "a", "given", "tag", "to", "log", "with", "level", "Info", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L111-L114
136,960
elodina/go_kafka_client
logger.go
Warn
func Warn(tag interface{}, message interface{}) { Logger.Warn(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), WarnLogTypeId, fmt.Sprintf("%s", message), nil)) }
go
func Warn(tag interface{}, message interface{}) { Logger.Warn(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), WarnLogTypeId, fmt.Sprintf("%s", message), nil)) }
[ "func", "Warn", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ")", "{", "Logger", ".", "Warn", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ")", ")", "\n", "EmitterLogs", ".", "Emit", "(", "...
//Writes a given message with a given tag to log with level Warn.
[ "Writes", "a", "given", "message", "with", "a", "given", "tag", "to", "log", "with", "level", "Warn", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L123-L126
136,961
elodina/go_kafka_client
logger.go
Error
func Error(tag interface{}, message interface{}) { Logger.Error(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), ErrorLogTypeId, fmt.Sprintf("%s", message), nil)) }
go
func Error(tag interface{}, message interface{}) { Logger.Error(fmt.Sprintf("[%s] %s", tag, message)) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), ErrorLogTypeId, fmt.Sprintf("%s", message), nil)) }
[ "func", "Error", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ")", "{", "Logger", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ")", ")", "\n", "EmitterLogs", ".", "Emit", "(", ...
//Writes a given message with a given tag to log with level Error.
[ "Writes", "a", "given", "message", "with", "a", "given", "tag", "to", "log", "with", "level", "Error", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L135-L138
136,962
elodina/go_kafka_client
logger.go
Criticalf
func Criticalf(tag interface{}, message interface{}, params ...interface{}) { Logger.Critical(fmt.Sprintf("[%s] %s", tag, message), params...) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), CriticalLogTypeId, fmt.Sprintf(fmt.Sprintf("%s", message), params...), nil)) }
go
func Criticalf(tag interface{}, message interface{}, params ...interface{}) { Logger.Critical(fmt.Sprintf("[%s] %s", tag, message), params...) EmitterLogs.Emit(newLogLine(fmt.Sprintf("%s", tag), CriticalLogTypeId, fmt.Sprintf(fmt.Sprintf("%s", message), params...), nil)) }
[ "func", "Criticalf", "(", "tag", "interface", "{", "}", ",", "message", "interface", "{", "}", ",", "params", "...", "interface", "{", "}", ")", "{", "Logger", ".", "Critical", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "tag", ",", "message", ...
//Formats a given message according to given params with a given tag to log with level Critical.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "with", "a", "given", "tag", "to", "log", "with", "level", "Critical", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L153-L156
136,963
elodina/go_kafka_client
logger.go
NewDefaultLogger
func NewDefaultLogger(Level LogLevel) *DefaultLogger { var config = fmt.Sprintf(`<seelog minlevel="%s"> <outputs formatid="main"> <console /> </outputs> <formats> <format id="main" format="%%Date/%%Time [%%LEVEL] %%Msg%%n"/> </formats> </seelog>`, Level) logger, _ := log.LoggerFromCon...
go
func NewDefaultLogger(Level LogLevel) *DefaultLogger { var config = fmt.Sprintf(`<seelog minlevel="%s"> <outputs formatid="main"> <console /> </outputs> <formats> <format id="main" format="%%Date/%%Time [%%LEVEL] %%Msg%%n"/> </formats> </seelog>`, Level) logger, _ := log.LoggerFromCon...
[ "func", "NewDefaultLogger", "(", "Level", "LogLevel", ")", "*", "DefaultLogger", "{", "var", "config", "=", "fmt", ".", "Sprintf", "(", "`<seelog minlevel=\"%s\">\n <outputs formatid=\"main\">\n <console />\n </outputs>\n\n <formats>\n <format id=\"main\" forma...
//Creates a new DefaultLogger that is configured to write messages to console with minimum log level Level.
[ "Creates", "a", "new", "DefaultLogger", "that", "is", "configured", "to", "write", "messages", "to", "console", "with", "minimum", "log", "level", "Level", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L165-L177
136,964
elodina/go_kafka_client
logger.go
Trace
func (dl *DefaultLogger) Trace(message string, params ...interface{}) { dl.logger.Tracef(message, params...) }
go
func (dl *DefaultLogger) Trace(message string, params ...interface{}) { dl.logger.Tracef(message, params...) }
[ "func", "(", "dl", "*", "DefaultLogger", ")", "Trace", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "dl", ".", "logger", ".", "Tracef", "(", "message", ",", "params", "...", ")", "\n", "}" ]
// Formats a given message according to given params to log with level Trace.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Trace", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L180-L182
136,965
elodina/go_kafka_client
logger.go
Debug
func (dl *DefaultLogger) Debug(message string, params ...interface{}) { dl.logger.Debugf(message, params...) }
go
func (dl *DefaultLogger) Debug(message string, params ...interface{}) { dl.logger.Debugf(message, params...) }
[ "func", "(", "dl", "*", "DefaultLogger", ")", "Debug", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "dl", ".", "logger", ".", "Debugf", "(", "message", ",", "params", "...", ")", "\n", "}" ]
//Formats a given message according to given params to log with level Debug.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Debug", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L185-L187
136,966
elodina/go_kafka_client
logger.go
Info
func (dl *DefaultLogger) Info(message string, params ...interface{}) { dl.logger.Infof(message, params...) }
go
func (dl *DefaultLogger) Info(message string, params ...interface{}) { dl.logger.Infof(message, params...) }
[ "func", "(", "dl", "*", "DefaultLogger", ")", "Info", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "dl", ".", "logger", ".", "Infof", "(", "message", ",", "params", "...", ")", "\n", "}" ]
//Formats a given message according to given params to log with level Info.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Info", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L190-L192
136,967
elodina/go_kafka_client
logger.go
Warn
func (dl *DefaultLogger) Warn(message string, params ...interface{}) { dl.logger.Warnf(message, params...) }
go
func (dl *DefaultLogger) Warn(message string, params ...interface{}) { dl.logger.Warnf(message, params...) }
[ "func", "(", "dl", "*", "DefaultLogger", ")", "Warn", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "dl", ".", "logger", ".", "Warnf", "(", "message", ",", "params", "...", ")", "\n", "}" ]
//Formats a given message according to given params to log with level Warn.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Warn", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L195-L197
136,968
elodina/go_kafka_client
logger.go
Error
func (dl *DefaultLogger) Error(message string, params ...interface{}) { dl.logger.Errorf(message, params...) }
go
func (dl *DefaultLogger) Error(message string, params ...interface{}) { dl.logger.Errorf(message, params...) }
[ "func", "(", "dl", "*", "DefaultLogger", ")", "Error", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "dl", ".", "logger", ".", "Errorf", "(", "message", ",", "params", "...", ")", "\n", "}" ]
//Formats a given message according to given params to log with level Error.
[ "Formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Error", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/logger.go#L200-L202
136,969
elodina/go_kafka_client
zk_coordinator.go
GetPartitionsForTopics
func (this *ZookeeperCoordinator) GetPartitionsForTopics(Topics []string) (partitions map[string][]int32, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { partitions, err = this.tryGetPartitionsForTopics(Topics) if err == nil { return } Tracef(this, "GetPartitionsFo...
go
func (this *ZookeeperCoordinator) GetPartitionsForTopics(Topics []string) (partitions map[string][]int32, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { partitions, err = this.tryGetPartitionsForTopics(Topics) if err == nil { return } Tracef(this, "GetPartitionsFo...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "GetPartitionsForTopics", "(", "Topics", "[", "]", "string", ")", "(", "partitions", "map", "[", "string", "]", "[", "]", "int32", ",", "err", "error", ")", "{", "backoffMultiplier", ":=", "1", "\n", ...
// Gets the information about existing partitions for a given Topics. // Returns a map where keys are topic names and values are slices of partition ids associated with this topic and error on failure.
[ "Gets", "the", "information", "about", "existing", "partitions", "for", "a", "given", "Topics", ".", "Returns", "a", "map", "where", "keys", "are", "topic", "names", "and", "values", "are", "slices", "of", "partition", "ids", "associated", "with", "this", "t...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L358-L370
136,970
elodina/go_kafka_client
zk_coordinator.go
GetAllBrokers
func (this *ZookeeperCoordinator) GetAllBrokers() (brokers []*BrokerInfo, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { brokers, err = this.tryGetAllBrokers() if err == nil { return } Tracef(this, "GetAllBrokers failed after %d-th retry", i) time.Sleep(this.con...
go
func (this *ZookeeperCoordinator) GetAllBrokers() (brokers []*BrokerInfo, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { brokers, err = this.tryGetAllBrokers() if err == nil { return } Tracef(this, "GetAllBrokers failed after %d-th retry", i) time.Sleep(this.con...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "GetAllBrokers", "(", ")", "(", "brokers", "[", "]", "*", "BrokerInfo", ",", "err", "error", ")", "{", "backoffMultiplier", ":=", "1", "\n", "for", "i", ":=", "0", ";", "i", "<=", "this", ".", "c...
// Gets the information about all Kafka brokers registered in this ConsumerCoordinator. // Returns a slice of BrokerInfo and error on failure.
[ "Gets", "the", "information", "about", "all", "Kafka", "brokers", "registered", "in", "this", "ConsumerCoordinator", ".", "Returns", "a", "slice", "of", "BrokerInfo", "and", "error", "on", "failure", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L393-L405
136,971
elodina/go_kafka_client
zk_coordinator.go
GetOffset
func (this *ZookeeperCoordinator) GetOffset(Groupid string, topic string, partition int32) (offset int64, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { offset, err = this.tryGetOffsetForTopicPartition(Groupid, topic, partition) if err == nil { return } Tracef(thi...
go
func (this *ZookeeperCoordinator) GetOffset(Groupid string, topic string, partition int32) (offset int64, err error) { backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { offset, err = this.tryGetOffsetForTopicPartition(Groupid, topic, partition) if err == nil { return } Tracef(thi...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "GetOffset", "(", "Groupid", "string", ",", "topic", "string", ",", "partition", "int32", ")", "(", "offset", "int64", ",", "err", "error", ")", "{", "backoffMultiplier", ":=", "1", "\n", "for", "i", ...
// Gets the offset for a given topic, partition and consumer group. // Returns offset on sucess, error otherwise.
[ "Gets", "the", "offset", "for", "a", "given", "topic", "partition", "and", "consumer", "group", ".", "Returns", "offset", "on", "sucess", "error", "otherwise", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L434-L446
136,972
elodina/go_kafka_client
zk_coordinator.go
ClaimPartitionOwnership
func (this *ZookeeperCoordinator) ClaimPartitionOwnership(Groupid string, Topic string, Partition int32, consumerThreadId ConsumerThreadId) (bool, error) { var err error backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { ok, err := this.tryClaimPartitionOwnership(Groupid, Topic, Partition...
go
func (this *ZookeeperCoordinator) ClaimPartitionOwnership(Groupid string, Topic string, Partition int32, consumerThreadId ConsumerThreadId) (bool, error) { var err error backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { ok, err := this.tryClaimPartitionOwnership(Groupid, Topic, Partition...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "ClaimPartitionOwnership", "(", "Groupid", "string", ",", "Topic", "string", ",", "Partition", "int32", ",", "consumerThreadId", "ConsumerThreadId", ")", "(", "bool", ",", "error", ")", "{", "var", "err", ...
// Tells the ConsumerCoordinator to claim partition topic Topic and partition Partition for consumerThreadId fetcher that works within a consumer group Group. // Returns true if claim is successful, false and error explaining failure otherwise.
[ "Tells", "the", "ConsumerCoordinator", "to", "claim", "partition", "topic", "Topic", "and", "partition", "Partition", "for", "consumerThreadId", "fetcher", "that", "works", "within", "a", "consumer", "group", "Group", ".", "Returns", "true", "if", "claim", "is", ...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L854-L867
136,973
elodina/go_kafka_client
zk_coordinator.go
ReleasePartitionOwnership
func (this *ZookeeperCoordinator) ReleasePartitionOwnership(Groupid string, Topic string, Partition int32) error { var err error backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { err = this.tryReleasePartitionOwnership(Groupid, Topic, Partition) if err == nil { return err } Trac...
go
func (this *ZookeeperCoordinator) ReleasePartitionOwnership(Groupid string, Topic string, Partition int32) error { var err error backoffMultiplier := 1 for i := 0; i <= this.config.MaxRequestRetries; i++ { err = this.tryReleasePartitionOwnership(Groupid, Topic, Partition) if err == nil { return err } Trac...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "ReleasePartitionOwnership", "(", "Groupid", "string", ",", "Topic", "string", ",", "Partition", "int32", ")", "error", "{", "var", "err", "error", "\n", "backoffMultiplier", ":=", "1", "\n", "for", "i", ...
// Tells the ConsumerCoordinator to release partition ownership on topic Topic and partition Partition for consumer group Groupid. // Returns error if failed to released partition ownership.
[ "Tells", "the", "ConsumerCoordinator", "to", "release", "partition", "ownership", "on", "topic", "Topic", "and", "partition", "Partition", "for", "consumer", "group", "Groupid", ".", "Returns", "error", "if", "failed", "to", "released", "partition", "ownership", "...
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L905-L918
136,974
elodina/go_kafka_client
zk_coordinator.go
CommitOffset
func (this *ZookeeperCoordinator) CommitOffset(Groupid string, Topic string, Partition int32, Offset int64) error { dirs := newZKGroupTopicDirs(this.config.Root, Groupid, Topic) err := this.updateRecord(fmt.Sprintf("%s/%d", dirs.ConsumerOffsetDir, Partition), []byte(strconv.FormatInt(Offset, 10))) if err == zk.ErrNo...
go
func (this *ZookeeperCoordinator) CommitOffset(Groupid string, Topic string, Partition int32, Offset int64) error { dirs := newZKGroupTopicDirs(this.config.Root, Groupid, Topic) err := this.updateRecord(fmt.Sprintf("%s/%d", dirs.ConsumerOffsetDir, Partition), []byte(strconv.FormatInt(Offset, 10))) if err == zk.ErrNo...
[ "func", "(", "this", "*", "ZookeeperCoordinator", ")", "CommitOffset", "(", "Groupid", "string", ",", "Topic", "string", ",", "Partition", "int32", ",", "Offset", "int64", ")", "error", "{", "dirs", ":=", "newZKGroupTopicDirs", "(", "this", ".", "config", "....
// Tells the ConsumerCoordinator to commit offset Offset for topic and partition TopicPartition for consumer group Groupid. // Returns error if failed to commit offset.
[ "Tells", "the", "ConsumerCoordinator", "to", "commit", "offset", "Offset", "for", "topic", "and", "partition", "TopicPartition", "for", "consumer", "group", "Groupid", ".", "Returns", "error", "if", "failed", "to", "commit", "offset", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/zk_coordinator.go#L932-L940
136,975
elodina/go_kafka_client
filter.go
NewWhiteList
func NewWhiteList(regex string) *WhiteList { cregexp, err := regexp.Compile(regex) if err != nil { panic(err) } return &WhiteList{ rawRegex: regex, compiledRegex: cregexp, } }
go
func NewWhiteList(regex string) *WhiteList { cregexp, err := regexp.Compile(regex) if err != nil { panic(err) } return &WhiteList{ rawRegex: regex, compiledRegex: cregexp, } }
[ "func", "NewWhiteList", "(", "regex", "string", ")", "*", "WhiteList", "{", "cregexp", ",", "err", ":=", "regexp", ".", "Compile", "(", "regex", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "&", "Wh...
//Creates a new WhiteList topic filter for a given regex
[ "Creates", "a", "new", "WhiteList", "topic", "filter", "for", "a", "given", "regex" ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/filter.go#L41-L50
136,976
elodina/go_kafka_client
filter.go
NewBlackList
func NewBlackList(regex string) *BlackList { cregexp, err := regexp.Compile(regex) if err != nil { panic(err) } return &BlackList{ rawRegex: regex, compiledRegex: cregexp, } }
go
func NewBlackList(regex string) *BlackList { cregexp, err := regexp.Compile(regex) if err != nil { panic(err) } return &BlackList{ rawRegex: regex, compiledRegex: cregexp, } }
[ "func", "NewBlackList", "(", "regex", "string", ")", "*", "BlackList", "{", "cregexp", ",", "err", ":=", "regexp", ".", "Compile", "(", "regex", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "&", "Bl...
//Creates a new BlackList topic filter for a given regex
[ "Creates", "a", "new", "BlackList", "topic", "filter", "for", "a", "given", "regex" ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/filter.go#L67-L76
136,977
elodina/go_kafka_client
log_emitters.go
Emit
func (k *KafkaLogEmitter) Emit(logLine *avro.LogLine) { if logLine.Logtypeid.(int64) >= logLevels[k.config.LogLevel] { k.producer.Send(&producer.ProducerRecord{ Topic: k.config.Topic, Value: logLine, }) } }
go
func (k *KafkaLogEmitter) Emit(logLine *avro.LogLine) { if logLine.Logtypeid.(int64) >= logLevels[k.config.LogLevel] { k.producer.Send(&producer.ProducerRecord{ Topic: k.config.Topic, Value: logLine, }) } }
[ "func", "(", "k", "*", "KafkaLogEmitter", ")", "Emit", "(", "logLine", "*", "avro", ".", "LogLine", ")", "{", "if", "logLine", ".", "Logtypeid", ".", "(", "int64", ")", ">=", "logLevels", "[", "k", ".", "config", ".", "LogLevel", "]", "{", "k", "."...
// Emit emits a single entry to a given destination topic.
[ "Emit", "emits", "a", "single", "entry", "to", "a", "given", "destination", "topic", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/log_emitters.go#L126-L133
136,978
elodina/go_kafka_client
log_emitters.go
Trace
func (k *KafkaLogEmitter) Trace(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, TraceLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
go
func (k *KafkaLogEmitter) Trace(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, TraceLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
[ "func", "(", "k", "*", "KafkaLogEmitter", ")", "Trace", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "k", ".", "Emit", "(", "newLogLine", "(", "k", ".", "config", ".", "Source", ",", "TraceLogTypeId", ",", "fmt", "...
// Trace formats a given message according to given params to log with level Trace and produces to a given Kafka topic.
[ "Trace", "formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Trace", "and", "produces", "to", "a", "given", "Kafka", "topic", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/log_emitters.go#L141-L143
136,979
elodina/go_kafka_client
log_emitters.go
Debug
func (k *KafkaLogEmitter) Debug(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, DebugLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
go
func (k *KafkaLogEmitter) Debug(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, DebugLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
[ "func", "(", "k", "*", "KafkaLogEmitter", ")", "Debug", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "k", ".", "Emit", "(", "newLogLine", "(", "k", ".", "config", ".", "Source", ",", "DebugLogTypeId", ",", "fmt", "...
// Debug formats a given message according to given params to log with level Debug and produces to a given Kafka topic.
[ "Debug", "formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Debug", "and", "produces", "to", "a", "given", "Kafka", "topic", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/log_emitters.go#L146-L148
136,980
elodina/go_kafka_client
log_emitters.go
Info
func (k *KafkaLogEmitter) Info(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, InfoLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
go
func (k *KafkaLogEmitter) Info(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, InfoLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
[ "func", "(", "k", "*", "KafkaLogEmitter", ")", "Info", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "k", ".", "Emit", "(", "newLogLine", "(", "k", ".", "config", ".", "Source", ",", "InfoLogTypeId", ",", "fmt", "."...
// Info formats a given message according to given params to log with level Info and produces to a given Kafka topic.
[ "Info", "formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Info", "and", "produces", "to", "a", "given", "Kafka", "topic", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/log_emitters.go#L151-L153
136,981
elodina/go_kafka_client
log_emitters.go
Warn
func (k *KafkaLogEmitter) Warn(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, WarnLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
go
func (k *KafkaLogEmitter) Warn(message string, params ...interface{}) { k.Emit(newLogLine(k.config.Source, WarnLogTypeId, fmt.Sprintf(message, params), k.config.Tags)) }
[ "func", "(", "k", "*", "KafkaLogEmitter", ")", "Warn", "(", "message", "string", ",", "params", "...", "interface", "{", "}", ")", "{", "k", ".", "Emit", "(", "newLogLine", "(", "k", ".", "config", ".", "Source", ",", "WarnLogTypeId", ",", "fmt", "."...
// Warn formats a given message according to given params to log with level Warn and produces to a given Kafka topic.
[ "Warn", "formats", "a", "given", "message", "according", "to", "given", "params", "to", "log", "with", "level", "Warn", "and", "produces", "to", "a", "given", "Kafka", "topic", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/log_emitters.go#L156-L158
136,982
elodina/go_kafka_client
mirror_maker.go
NewMirrorMakerConfig
func NewMirrorMakerConfig() *MirrorMakerConfig { return &MirrorMakerConfig{ KeyEncoder: producer.ByteSerializer, ValueEncoder: producer.ByteSerializer, KeyDecoder: &ByteDecoder{}, ValueDecoder: &ByteDecoder{}, } }
go
func NewMirrorMakerConfig() *MirrorMakerConfig { return &MirrorMakerConfig{ KeyEncoder: producer.ByteSerializer, ValueEncoder: producer.ByteSerializer, KeyDecoder: &ByteDecoder{}, ValueDecoder: &ByteDecoder{}, } }
[ "func", "NewMirrorMakerConfig", "(", ")", "*", "MirrorMakerConfig", "{", "return", "&", "MirrorMakerConfig", "{", "KeyEncoder", ":", "producer", ".", "ByteSerializer", ",", "ValueEncoder", ":", "producer", ".", "ByteSerializer", ",", "KeyDecoder", ":", "&", "ByteD...
// Creates an empty MirrorMakerConfig.
[ "Creates", "an", "empty", "MirrorMakerConfig", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/mirror_maker.go#L71-L78
136,983
elodina/go_kafka_client
mirror_maker.go
Start
func (this *MirrorMaker) Start() { this.initializeMessageChannels() this.startConsumers() this.startProducers() <-this.stopped }
go
func (this *MirrorMaker) Start() { this.initializeMessageChannels() this.startConsumers() this.startProducers() <-this.stopped }
[ "func", "(", "this", "*", "MirrorMaker", ")", "Start", "(", ")", "{", "this", ".", "initializeMessageChannels", "(", ")", "\n", "this", ".", "startConsumers", "(", ")", "\n", "this", ".", "startProducers", "(", ")", "\n", "<-", "this", ".", "stopped", ...
// Starts the MirrorMaker. This method is blocking and should probably be run in a separate goroutine.
[ "Starts", "the", "MirrorMaker", ".", "This", "method", "is", "blocking", "and", "should", "probably", "be", "run", "in", "a", "separate", "goroutine", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/mirror_maker.go#L100-L105
136,984
elodina/go_kafka_client
mirror_maker.go
Stop
func (this *MirrorMaker) Stop() { consumerCloseChannels := make([]<-chan bool, 0) for _, consumer := range this.consumers { consumerCloseChannels = append(consumerCloseChannels, consumer.Close()) } for _, ch := range consumerCloseChannels { <-ch } for _, ch := range this.messageChannels { close(ch) } /...
go
func (this *MirrorMaker) Stop() { consumerCloseChannels := make([]<-chan bool, 0) for _, consumer := range this.consumers { consumerCloseChannels = append(consumerCloseChannels, consumer.Close()) } for _, ch := range consumerCloseChannels { <-ch } for _, ch := range this.messageChannels { close(ch) } /...
[ "func", "(", "this", "*", "MirrorMaker", ")", "Stop", "(", ")", "{", "consumerCloseChannels", ":=", "make", "(", "[", "]", "<-", "chan", "bool", ",", "0", ")", "\n", "for", "_", ",", "consumer", ":=", "range", "this", ".", "consumers", "{", "consumer...
// Gracefully stops the MirrorMaker.
[ "Gracefully", "stops", "the", "MirrorMaker", "." ]
95d107b0c102fa81b8c1e5e556adc23352fad065
https://github.com/elodina/go_kafka_client/blob/95d107b0c102fa81b8c1e5e556adc23352fad065/mirror_maker.go#L108-L130
136,985
icza/session
session.go
NewSessionOptions
func NewSessionOptions(o *SessOptions) Session { now := time.Now() idLength := o.IDLength if idLength <= 0 { idLength = 18 } timeout := o.Timeout if timeout == 0 { timeout = 30 * time.Minute } sess := sessionImpl{ IDF: genID(idLength), CreatedF: now, AccessedF: now, AttrsF: make(map[strin...
go
func NewSessionOptions(o *SessOptions) Session { now := time.Now() idLength := o.IDLength if idLength <= 0 { idLength = 18 } timeout := o.Timeout if timeout == 0 { timeout = 30 * time.Minute } sess := sessionImpl{ IDF: genID(idLength), CreatedF: now, AccessedF: now, AttrsF: make(map[strin...
[ "func", "NewSessionOptions", "(", "o", "*", "SessOptions", ")", "Session", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "idLength", ":=", "o", ".", "IDLength", "\n", "if", "idLength", "<=", "0", "{", "idLength", "=", "18", "\n", "}", "\n", ...
// NewSessionOptions creates a new Session with the specified options.
[ "NewSessionOptions", "creates", "a", "new", "Session", "with", "the", "specified", "options", "." ]
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/session.go#L114-L146
136,986
icza/session
cookie_manager.go
NewCookieManagerOptions
func NewCookieManagerOptions(store Store, o *CookieMngrOptions) Manager { m := &CookieManager{ store: store, cookieSecure: !o.AllowHTTP, sessIDCookieName: o.SessIDCookieName, cookiePath: o.CookiePath, } if m.sessIDCookieName == "" { m.sessIDCookieName = "sessid" } if o.CookieMaxAge ...
go
func NewCookieManagerOptions(store Store, o *CookieMngrOptions) Manager { m := &CookieManager{ store: store, cookieSecure: !o.AllowHTTP, sessIDCookieName: o.SessIDCookieName, cookiePath: o.CookiePath, } if m.sessIDCookieName == "" { m.sessIDCookieName = "sessid" } if o.CookieMaxAge ...
[ "func", "NewCookieManagerOptions", "(", "store", "Store", ",", "o", "*", "CookieMngrOptions", ")", "Manager", "{", "m", ":=", "&", "CookieManager", "{", "store", ":", "store", ",", "cookieSecure", ":", "!", "o", ".", "AllowHTTP", ",", "sessIDCookieName", ":"...
// NewCookieManagerOptions creates a new, cookie based session Manager with the specified options.
[ "NewCookieManagerOptions", "creates", "a", "new", "cookie", "based", "session", "Manager", "with", "the", "specified", "options", "." ]
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/cookie_manager.go#L52-L73
136,987
icza/session
gae_memcache_store.go
NewMemcacheStoreOptions
func NewMemcacheStoreOptions(ctx context.Context, o *MemcacheStoreOptions) Store { s := &memcacheStore{ ctx: ctx, keyPrefix: o.KeyPrefix, retries: o.Retries, onlyMemcache: o.OnlyMemcache, asyncDatastoreSave: o.AsyncDatastoreSave, dsEntityName: o.DSEntityName, ...
go
func NewMemcacheStoreOptions(ctx context.Context, o *MemcacheStoreOptions) Store { s := &memcacheStore{ ctx: ctx, keyPrefix: o.KeyPrefix, retries: o.Retries, onlyMemcache: o.OnlyMemcache, asyncDatastoreSave: o.AsyncDatastoreSave, dsEntityName: o.DSEntityName, ...
[ "func", "NewMemcacheStoreOptions", "(", "ctx", "context", ".", "Context", ",", "o", "*", "MemcacheStoreOptions", ")", "Store", "{", "s", ":=", "&", "memcacheStore", "{", "ctx", ":", "ctx", ",", "keyPrefix", ":", "o", ".", "KeyPrefix", ",", "retries", ":", ...
// NewMemcacheStoreOptions returns a new, GAE Memcache session Store with the specified options. // // Important! Since accessing the Memcache relies on Appengine Context // which is bound to an http.Request, the returned Store can only be used for the lifetime of a request!
[ "NewMemcacheStoreOptions", "returns", "a", "new", "GAE", "Memcache", "session", "Store", "with", "the", "specified", "options", ".", "Important!", "Since", "accessing", "the", "Memcache", "relies", "on", "Appengine", "Context", "which", "is", "bound", "to", "an", ...
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/gae_memcache_store.go#L124-L147
136,988
icza/session
gae_memcache_store.go
setMemcacheSession
func (s *memcacheStore) setMemcacheSession(sess Session) (success bool) { item := &memcache.Item{ Key: s.keyPrefix + sess.ID(), Object: sess, Expiration: sess.Timeout(), } var err error for i := 0; i < s.retries; i++ { if err = s.codec.Set(s.ctx, item); err == nil { return true } } log.E...
go
func (s *memcacheStore) setMemcacheSession(sess Session) (success bool) { item := &memcache.Item{ Key: s.keyPrefix + sess.ID(), Object: sess, Expiration: sess.Timeout(), } var err error for i := 0; i < s.retries; i++ { if err = s.codec.Set(s.ctx, item); err == nil { return true } } log.E...
[ "func", "(", "s", "*", "memcacheStore", ")", "setMemcacheSession", "(", "sess", "Session", ")", "(", "success", "bool", ")", "{", "item", ":=", "&", "memcache", ".", "Item", "{", "Key", ":", "s", ".", "keyPrefix", "+", "sess", ".", "ID", "(", ")", ...
// setMemcacheSession sets the specified session in the Memcache.
[ "setMemcacheSession", "sets", "the", "specified", "session", "in", "the", "Memcache", "." ]
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/gae_memcache_store.go#L237-L253
136,989
icza/session
gae_memcache_store.go
saveToDatastore
func (s *memcacheStore) saveToDatastore() { // Save sessions that were accessed from this store. No need locking, we're closing... // We could use datastore.PutMulti(), but sessions will contain at most 1 session like all the times. for _, sess := range s.sessions { value, err := s.codec.Marshal(sess) if err != ...
go
func (s *memcacheStore) saveToDatastore() { // Save sessions that were accessed from this store. No need locking, we're closing... // We could use datastore.PutMulti(), but sessions will contain at most 1 session like all the times. for _, sess := range s.sessions { value, err := s.codec.Marshal(sess) if err != ...
[ "func", "(", "s", "*", "memcacheStore", ")", "saveToDatastore", "(", ")", "{", "// Save sessions that were accessed from this store. No need locking, we're closing...", "// We could use datastore.PutMulti(), but sessions will contain at most 1 session like all the times.", "for", "_", ",...
// saveToDatastore saves the sessions of the Store to the Datastore // in the caller's goroutine.
[ "saveToDatastore", "saves", "the", "sessions", "of", "the", "Store", "to", "the", "Datastore", "in", "the", "caller", "s", "goroutine", "." ]
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/gae_memcache_store.go#L297-L320
136,990
icza/session
inmem_store.go
NewInMemStoreOptions
func NewInMemStoreOptions(o *InMemStoreOptions) Store { s := &inMemStore{ sessions: make(map[string]Session), mux: &sync.RWMutex{}, closeTicker: make(chan struct{}), } output := log.Output if o.Logger != nil { output = o.Logger.Output } s.logPrintln = func(v ...interface{}) { output(3, fmt.S...
go
func NewInMemStoreOptions(o *InMemStoreOptions) Store { s := &inMemStore{ sessions: make(map[string]Session), mux: &sync.RWMutex{}, closeTicker: make(chan struct{}), } output := log.Output if o.Logger != nil { output = o.Logger.Output } s.logPrintln = func(v ...interface{}) { output(3, fmt.S...
[ "func", "NewInMemStoreOptions", "(", "o", "*", "InMemStoreOptions", ")", "Store", "{", "s", ":=", "&", "inMemStore", "{", "sessions", ":", "make", "(", "map", "[", "string", "]", "Session", ")", ",", "mux", ":", "&", "sync", ".", "RWMutex", "{", "}", ...
// NewInMemStoreOptions returns a new, in-memory session Store with the specified options. // The returned Store has an automatic session cleaner which runs // in its own goroutine.
[ "NewInMemStoreOptions", "returns", "a", "new", "in", "-", "memory", "session", "Store", "with", "the", "specified", "options", ".", "The", "returned", "Store", "has", "an", "automatic", "session", "cleaner", "which", "runs", "in", "its", "own", "goroutine", "....
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/inmem_store.go#L55-L78
136,991
icza/session
inmem_store.go
sessCleaner
func (s *inMemStore) sessCleaner(interval time.Duration) { ticker := time.NewTicker(interval) for { select { case <-s.closeTicker: // We are being shut down... ticker.Stop() return case now := <-ticker.C: // Do a sweep. // Remove is very rare compared to the number of checks, so: // "Quick" c...
go
func (s *inMemStore) sessCleaner(interval time.Duration) { ticker := time.NewTicker(interval) for { select { case <-s.closeTicker: // We are being shut down... ticker.Stop() return case now := <-ticker.C: // Do a sweep. // Remove is very rare compared to the number of checks, so: // "Quick" c...
[ "func", "(", "s", "*", "inMemStore", ")", "sessCleaner", "(", "interval", "time", ".", "Duration", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "interval", ")", "\n\n", "for", "{", "select", "{", "case", "<-", "s", ".", "closeTicker", ":", ...
// sessCleaner periodically checks whether sessions have timed out // in an endless loop. If a session has timed out, removes it. // This method is to be started as a new goroutine.
[ "sessCleaner", "periodically", "checks", "whether", "sessions", "have", "timed", "out", "in", "an", "endless", "loop", ".", "If", "a", "session", "has", "timed", "out", "removes", "it", ".", "This", "method", "is", "to", "be", "started", "as", "a", "new", ...
5815dfd32323e41eac8afea307a6aa42c49e2a69
https://github.com/icza/session/blob/5815dfd32323e41eac8afea307a6aa42c49e2a69/inmem_store.go#L83-L127
136,992
sajari/word2vec
http.go
NewServer
func NewServer(c Coser) http.Handler { ms := &server{ Coser: c, } mux := http.NewServeMux() mux.HandleFunc("/cos-n", ms.handleCosNQuery) mux.HandleFunc("/cos", ms.handleCosQuery) mux.HandleFunc("/coses", ms.handleCosesQuery) ms.ServeMux = mux return ms }
go
func NewServer(c Coser) http.Handler { ms := &server{ Coser: c, } mux := http.NewServeMux() mux.HandleFunc("/cos-n", ms.handleCosNQuery) mux.HandleFunc("/cos", ms.handleCosQuery) mux.HandleFunc("/coses", ms.handleCosesQuery) ms.ServeMux = mux return ms }
[ "func", "NewServer", "(", "c", "Coser", ")", "http", ".", "Handler", "{", "ms", ":=", "&", "server", "{", "Coser", ":", "c", ",", "}", "\n\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "mux", ".", "HandleFunc", "(", "\"", "\"", ","...
// NewServer creates a new word2vec server which exports endpoints for performing // similarity queries on a word2vec Model.
[ "NewServer", "creates", "a", "new", "word2vec", "server", "which", "exports", "endpoints", "for", "performing", "similarity", "queries", "on", "a", "word2vec", "Model", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/http.go#L88-L100
136,993
sajari/word2vec
http.go
Coses
func (c Client) Coses(pairs [][2]Expr) ([]float32, error) { req := cosesQuery{ A: make([]Expr, len(pairs)), B: make([]Expr, len(pairs)), } for i, pair := range pairs { req.A[i] = pair[0] req.B[i] = pair[1] } body, err := c.fetch(req, "coses") if err != nil { return nil, err } var data cosesResponse ...
go
func (c Client) Coses(pairs [][2]Expr) ([]float32, error) { req := cosesQuery{ A: make([]Expr, len(pairs)), B: make([]Expr, len(pairs)), } for i, pair := range pairs { req.A[i] = pair[0] req.B[i] = pair[1] } body, err := c.fetch(req, "coses") if err != nil { return nil, err } var data cosesResponse ...
[ "func", "(", "c", "Client", ")", "Coses", "(", "pairs", "[", "]", "[", "2", "]", "Expr", ")", "(", "[", "]", "float32", ",", "error", ")", "{", "req", ":=", "cosesQuery", "{", "A", ":", "make", "(", "[", "]", "Expr", ",", "len", "(", "pairs",...
// Coses implements Coser.
[ "Coses", "implements", "Coser", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/http.go#L240-L261
136,994
sajari/word2vec
cache.go
NewCache
func NewCache(c Coser) Coser { return &cache{ Coser: c, cache: make(map[string]float32), errCache: make(map[string]error), cosnCache: make(map[string][]Match), } }
go
func NewCache(c Coser) Coser { return &cache{ Coser: c, cache: make(map[string]float32), errCache: make(map[string]error), cosnCache: make(map[string][]Match), } }
[ "func", "NewCache", "(", "c", "Coser", ")", "Coser", "{", "return", "&", "cache", "{", "Coser", ":", "c", ",", "cache", ":", "make", "(", "map", "[", "string", "]", "float32", ")", ",", "errCache", ":", "make", "(", "map", "[", "string", "]", "er...
// NewCache returns a Coser which will cache repeated calls to the Cos method, // particularly useful when using Client.
[ "NewCache", "returns", "a", "Coser", "which", "will", "cache", "repeated", "calls", "to", "the", "Cos", "method", "particularly", "useful", "when", "using", "Client", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/cache.go#L11-L18
136,995
sajari/word2vec
partition/partition.go
Class
func (p *Partition) Class(w string) (int, error) { n, ok := p.words[w] if !ok { return 0, &NotFoundError{w} } return n, nil }
go
func (p *Partition) Class(w string) (int, error) { n, ok := p.words[w] if !ok { return 0, &NotFoundError{w} } return n, nil }
[ "func", "(", "p", "*", "Partition", ")", "Class", "(", "w", "string", ")", "(", "int", ",", "error", ")", "{", "n", ",", "ok", ":=", "p", ".", "words", "[", "w", "]", "\n", "if", "!", "ok", "{", "return", "0", ",", "&", "NotFoundError", "{", ...
// Class returns the internal index used to represent he equivalence class for w.
[ "Class", "returns", "the", "internal", "index", "used", "to", "represent", "he", "equivalence", "class", "for", "w", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/partition/partition.go#L79-L85
136,996
sajari/word2vec
partition/partition.go
Equiv
func (p *Partition) Equiv(w, v string) (bool, error) { i, ok := p.words[w] if !ok { return false, &NotFoundError{w} } j, ok := p.words[v] if !ok { return false, &NotFoundError{v} } return i == j, nil }
go
func (p *Partition) Equiv(w, v string) (bool, error) { i, ok := p.words[w] if !ok { return false, &NotFoundError{w} } j, ok := p.words[v] if !ok { return false, &NotFoundError{v} } return i == j, nil }
[ "func", "(", "p", "*", "Partition", ")", "Equiv", "(", "w", ",", "v", "string", ")", "(", "bool", ",", "error", ")", "{", "i", ",", "ok", ":=", "p", ".", "words", "[", "w", "]", "\n", "if", "!", "ok", "{", "return", "false", ",", "&", "NotF...
// Equiv returns true iff w and v are equivalent.
[ "Equiv", "returns", "true", "iff", "w", "and", "v", "are", "equivalent", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/partition/partition.go#L88-L98
136,997
sajari/word2vec
partition/partition.go
EquivClass
func (p *Partition) EquivClass(w string) ([]string, error) { i, ok := p.words[w] if !ok { return nil, &NotFoundError{w} } return p.classes[i], nil }
go
func (p *Partition) EquivClass(w string) ([]string, error) { i, ok := p.words[w] if !ok { return nil, &NotFoundError{w} } return p.classes[i], nil }
[ "func", "(", "p", "*", "Partition", ")", "EquivClass", "(", "w", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "i", ",", "ok", ":=", "p", ".", "words", "[", "w", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "&", ...
// EquivClass returns the equivalence class of w as the list of strings which are // equivalent to it.
[ "EquivClass", "returns", "the", "equivalence", "class", "of", "w", "as", "the", "list", "of", "strings", "which", "are", "equivalent", "to", "it", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/partition/partition.go#L102-L108
136,998
sajari/word2vec
word2vec.go
FromReader
func FromReader(r io.Reader) (*Model, error) { br := bufio.NewReader(r) var size, dim int n, err := fmt.Fscanln(r, &size, &dim) if err != nil { return nil, err } if n != 2 { return nil, fmt.Errorf("could not extract size/dim from binary model data") } m := &Model{ words: make(map[string]Vector, size), ...
go
func FromReader(r io.Reader) (*Model, error) { br := bufio.NewReader(r) var size, dim int n, err := fmt.Fscanln(r, &size, &dim) if err != nil { return nil, err } if n != 2 { return nil, fmt.Errorf("could not extract size/dim from binary model data") } m := &Model{ words: make(map[string]Vector, size), ...
[ "func", "FromReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Model", ",", "error", ")", "{", "br", ":=", "bufio", ".", "NewReader", "(", "r", ")", "\n", "var", "size", ",", "dim", "int", "\n", "n", ",", "err", ":=", "fmt", ".", "Fscanln...
// FromReader creates a Model using the binary model data provided by the io.Reader.
[ "FromReader", "creates", "a", "Model", "using", "the", "binary", "model", "data", "provided", "by", "the", "io", ".", "Reader", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/word2vec.go#L28-L76
136,999
sajari/word2vec
word2vec.go
Normalise
func (v Vector) Normalise() { w := blas.Snrm2(len(v), v, 1) blas.Sscal(len(v), 1/w, v, 1) }
go
func (v Vector) Normalise() { w := blas.Snrm2(len(v), v, 1) blas.Sscal(len(v), 1/w, v, 1) }
[ "func", "(", "v", "Vector", ")", "Normalise", "(", ")", "{", "w", ":=", "blas", ".", "Snrm2", "(", "len", "(", "v", ")", ",", "v", ",", "1", ")", "\n", "blas", ".", "Sscal", "(", "len", "(", "v", ")", ",", "1", "/", "w", ",", "v", ",", ...
// Normalise normalises the vector in-place.
[ "Normalise", "normalises", "the", "vector", "in", "-", "place", "." ]
350028ca6b1214bc12c20ff3b466733e1d0af3ac
https://github.com/sajari/word2vec/blob/350028ca6b1214bc12c20ff3b466733e1d0af3ac/word2vec.go#L82-L85