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
126,800
go-kit/kit
transport/awslambda/handler.go
HandlerBefore
func HandlerBefore(before ...HandlerRequestFunc) HandlerOption { return func(h *Handler) { h.before = append(h.before, before...) } }
go
func HandlerBefore(before ...HandlerRequestFunc) HandlerOption { return func(h *Handler) { h.before = append(h.before, before...) } }
[ "func", "HandlerBefore", "(", "before", "...", "HandlerRequestFunc", ")", "HandlerOption", "{", "return", "func", "(", "h", "*", "Handler", ")", "{", "h", ".", "before", "=", "append", "(", "h", ".", "before", ",", "before", "...", ")", "}", "\n", "}" ...
// HandlerBefore functions are executed on the payload byte, // before the request is decoded.
[ "HandlerBefore", "functions", "are", "executed", "on", "the", "payload", "byte", "before", "the", "request", "is", "decoded", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L49-L51
126,801
go-kit/kit
transport/awslambda/handler.go
HandlerAfter
func HandlerAfter(after ...HandlerResponseFunc) HandlerOption { return func(h *Handler) { h.after = append(h.after, after...) } }
go
func HandlerAfter(after ...HandlerResponseFunc) HandlerOption { return func(h *Handler) { h.after = append(h.after, after...) } }
[ "func", "HandlerAfter", "(", "after", "...", "HandlerResponseFunc", ")", "HandlerOption", "{", "return", "func", "(", "h", "*", "Handler", ")", "{", "h", ".", "after", "=", "append", "(", "h", ".", "after", ",", "after", "...", ")", "}", "\n", "}" ]
// HandlerAfter functions are only executed after invoking the endpoint // but prior to returning a response.
[ "HandlerAfter", "functions", "are", "only", "executed", "after", "invoking", "the", "endpoint", "but", "prior", "to", "returning", "a", "response", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L55-L57
126,802
go-kit/kit
transport/awslambda/handler.go
HandlerErrorHandler
func HandlerErrorHandler(errorHandler transport.ErrorHandler) HandlerOption { return func(h *Handler) { h.errorHandler = errorHandler } }
go
func HandlerErrorHandler(errorHandler transport.ErrorHandler) HandlerOption { return func(h *Handler) { h.errorHandler = errorHandler } }
[ "func", "HandlerErrorHandler", "(", "errorHandler", "transport", ".", "ErrorHandler", ")", "HandlerOption", "{", "return", "func", "(", "h", "*", "Handler", ")", "{", "h", ".", "errorHandler", "=", "errorHandler", "}", "\n", "}" ]
// HandlerErrorHandler is used to handle non-terminal errors. // By default, non-terminal errors are ignored.
[ "HandlerErrorHandler", "is", "used", "to", "handle", "non", "-", "terminal", "errors", ".", "By", "default", "non", "-", "terminal", "errors", "are", "ignored", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L68-L70
126,803
go-kit/kit
transport/awslambda/handler.go
HandlerFinalizer
func HandlerFinalizer(f ...HandlerFinalizerFunc) HandlerOption { return func(h *Handler) { h.finalizer = append(h.finalizer, f...) } }
go
func HandlerFinalizer(f ...HandlerFinalizerFunc) HandlerOption { return func(h *Handler) { h.finalizer = append(h.finalizer, f...) } }
[ "func", "HandlerFinalizer", "(", "f", "...", "HandlerFinalizerFunc", ")", "HandlerOption", "{", "return", "func", "(", "h", "*", "Handler", ")", "{", "h", ".", "finalizer", "=", "append", "(", "h", ".", "finalizer", ",", "f", "...", ")", "}", "\n", "}"...
// HandlerFinalizer sets finalizer which are called at the end of // request. By default no finalizer is registered.
[ "HandlerFinalizer", "sets", "finalizer", "which", "are", "called", "at", "the", "end", "of", "request", ".", "By", "default", "no", "finalizer", "is", "registered", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L79-L81
126,804
go-kit/kit
transport/awslambda/handler.go
DefaultErrorEncoder
func DefaultErrorEncoder(ctx context.Context, err error) ([]byte, error) { return nil, err }
go
func DefaultErrorEncoder(ctx context.Context, err error) ([]byte, error) { return nil, err }
[ "func", "DefaultErrorEncoder", "(", "ctx", "context", ".", "Context", ",", "err", "error", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "nil", ",", "err", "\n", "}" ]
// DefaultErrorEncoder defines the default behavior of encoding an error response, // where it returns nil, and the error itself.
[ "DefaultErrorEncoder", "defines", "the", "default", "behavior", "of", "encoding", "an", "error", "response", "where", "it", "returns", "nil", "and", "the", "error", "itself", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L85-L87
126,805
go-kit/kit
transport/awslambda/handler.go
Invoke
func (h *Handler) Invoke( ctx context.Context, payload []byte, ) (resp []byte, err error) { if len(h.finalizer) > 0 { defer func() { for _, f := range h.finalizer { f(ctx, resp, err) } }() } for _, f := range h.before { ctx = f(ctx, payload) } request, err := h.dec(ctx, payload) if err != nil ...
go
func (h *Handler) Invoke( ctx context.Context, payload []byte, ) (resp []byte, err error) { if len(h.finalizer) > 0 { defer func() { for _, f := range h.finalizer { f(ctx, resp, err) } }() } for _, f := range h.before { ctx = f(ctx, payload) } request, err := h.dec(ctx, payload) if err != nil ...
[ "func", "(", "h", "*", "Handler", ")", "Invoke", "(", "ctx", "context", ".", "Context", ",", "payload", "[", "]", "byte", ",", ")", "(", "resp", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "h", ".", "finalizer", ")", ">",...
// Invoke represents implementation of the AWS lambda.Handler interface.
[ "Invoke", "represents", "implementation", "of", "the", "AWS", "lambda", ".", "Handler", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/awslambda/handler.go#L90-L128
126,806
go-kit/kit
log/stdlib.go
NewStdlibAdapter
func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { a := StdlibAdapter{ Logger: logger, timestampKey: "ts", fileKey: "caller", messageKey: "msg", } for _, option := range options { option(&a) } return a }
go
func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { a := StdlibAdapter{ Logger: logger, timestampKey: "ts", fileKey: "caller", messageKey: "msg", } for _, option := range options { option(&a) } return a }
[ "func", "NewStdlibAdapter", "(", "logger", "Logger", ",", "options", "...", "StdlibAdapterOption", ")", "io", ".", "Writer", "{", "a", ":=", "StdlibAdapter", "{", "Logger", ":", "logger", ",", "timestampKey", ":", "\"", "\"", ",", "fileKey", ":", "\"", "\"...
// NewStdlibAdapter returns a new StdlibAdapter wrapper around the passed // logger. It's designed to be passed to log.SetOutput.
[ "NewStdlibAdapter", "returns", "a", "new", "StdlibAdapter", "wrapper", "around", "the", "passed", "logger", ".", "It", "s", "designed", "to", "be", "passed", "to", "log", ".", "SetOutput", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/stdlib.go#L54-L65
126,807
go-kit/kit
tracing/opentracing/grpc.go
ContextToGRPC
func ContextToGRPC(tracer opentracing.Tracer, logger log.Logger) func(ctx context.Context, md *metadata.MD) context.Context { return func(ctx context.Context, md *metadata.MD) context.Context { if span := opentracing.SpanFromContext(ctx); span != nil { // There's nothing we can do with an error here. if err :=...
go
func ContextToGRPC(tracer opentracing.Tracer, logger log.Logger) func(ctx context.Context, md *metadata.MD) context.Context { return func(ctx context.Context, md *metadata.MD) context.Context { if span := opentracing.SpanFromContext(ctx); span != nil { // There's nothing we can do with an error here. if err :=...
[ "func", "ContextToGRPC", "(", "tracer", "opentracing", ".", "Tracer", ",", "logger", "log", ".", "Logger", ")", "func", "(", "ctx", "context", ".", "Context", ",", "md", "*", "metadata", ".", "MD", ")", "context", ".", "Context", "{", "return", "func", ...
// ContextToGRPC returns a grpc RequestFunc that injects an OpenTracing Span // found in `ctx` into the grpc Metadata. If no such Span can be found, the // RequestFunc is a noop.
[ "ContextToGRPC", "returns", "a", "grpc", "RequestFunc", "that", "injects", "an", "OpenTracing", "Span", "found", "in", "ctx", "into", "the", "grpc", "Metadata", ".", "If", "no", "such", "Span", "can", "be", "found", "the", "RequestFunc", "is", "a", "noop", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opentracing/grpc.go#L18-L28
126,808
go-kit/kit
examples/addsvc/pkg/addservice/service.go
New
func New(logger log.Logger, ints, chars metrics.Counter) Service { var svc Service { svc = NewBasicService() svc = LoggingMiddleware(logger)(svc) svc = InstrumentingMiddleware(ints, chars)(svc) } return svc }
go
func New(logger log.Logger, ints, chars metrics.Counter) Service { var svc Service { svc = NewBasicService() svc = LoggingMiddleware(logger)(svc) svc = InstrumentingMiddleware(ints, chars)(svc) } return svc }
[ "func", "New", "(", "logger", "log", ".", "Logger", ",", "ints", ",", "chars", "metrics", ".", "Counter", ")", "Service", "{", "var", "svc", "Service", "\n", "{", "svc", "=", "NewBasicService", "(", ")", "\n", "svc", "=", "LoggingMiddleware", "(", "log...
// New returns a basic Service with all of the expected middlewares wired in.
[ "New", "returns", "a", "basic", "Service", "with", "all", "of", "the", "expected", "middlewares", "wired", "in", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addservice/service.go#L18-L26
126,809
go-kit/kit
examples/addsvc/pkg/addservice/service.go
Concat
func (s basicService) Concat(_ context.Context, a, b string) (string, error) { if len(a)+len(b) > maxLen { return "", ErrMaxSizeExceeded } return a + b, nil }
go
func (s basicService) Concat(_ context.Context, a, b string) (string, error) { if len(a)+len(b) > maxLen { return "", ErrMaxSizeExceeded } return a + b, nil }
[ "func", "(", "s", "basicService", ")", "Concat", "(", "_", "context", ".", "Context", ",", "a", ",", "b", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "a", ")", "+", "len", "(", "b", ")", ">", "maxLen", "{", "return",...
// Concat implements Service.
[ "Concat", "implements", "Service", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addservice/service.go#L66-L71
126,810
go-kit/kit
transport/nats/subscriber.go
ServeMsg
func (s Subscriber) ServeMsg(nc *nats.Conn) func(msg *nats.Msg) { return func(msg *nats.Msg) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() if len(s.finalizer) > 0 { defer func() { for _, f := range s.finalizer { f(ctx, msg) } }() } for _, f := range s.before { ...
go
func (s Subscriber) ServeMsg(nc *nats.Conn) func(msg *nats.Msg) { return func(msg *nats.Msg) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() if len(s.finalizer) > 0 { defer func() { for _, f := range s.finalizer { f(ctx, msg) } }() } for _, f := range s.before { ...
[ "func", "(", "s", "Subscriber", ")", "ServeMsg", "(", "nc", "*", "nats", ".", "Conn", ")", "func", "(", "msg", "*", "nats", ".", "Msg", ")", "{", "return", "func", "(", "msg", "*", "nats", ".", "Msg", ")", "{", "ctx", ",", "cancel", ":=", "cont...
// ServeMsg provides nats.MsgHandler.
[ "ServeMsg", "provides", "nats", ".", "MsgHandler", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/nats/subscriber.go#L94-L145
126,811
go-kit/kit
transport/nats/subscriber.go
EncodeJSONResponse
func EncodeJSONResponse(_ context.Context, reply string, nc *nats.Conn, response interface{}) error { b, err := json.Marshal(response) if err != nil { return err } return nc.Publish(reply, b) }
go
func EncodeJSONResponse(_ context.Context, reply string, nc *nats.Conn, response interface{}) error { b, err := json.Marshal(response) if err != nil { return err } return nc.Publish(reply, b) }
[ "func", "EncodeJSONResponse", "(", "_", "context", ".", "Context", ",", "reply", "string", ",", "nc", "*", "nats", ".", "Conn", ",", "response", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "response", ...
// EncodeJSONResponse is a EncodeResponseFunc that serializes the response as a // JSON object to the subscriber reply. Many JSON-over services can use it as // a sensible default.
[ "EncodeJSONResponse", "is", "a", "EncodeResponseFunc", "that", "serializes", "the", "response", "as", "a", "JSON", "object", "to", "the", "subscriber", "reply", ".", "Many", "JSON", "-", "over", "services", "can", "use", "it", "as", "a", "sensible", "default",...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/nats/subscriber.go#L167-L174
126,812
go-kit/kit
transport/nats/subscriber.go
DefaultErrorEncoder
func DefaultErrorEncoder(_ context.Context, err error, reply string, nc *nats.Conn) { logger := log.NewNopLogger() type Response struct { Error string `json:"err"` } var response Response response.Error = err.Error() b, err := json.Marshal(response) if err != nil { logger.Log("err", err) return } if...
go
func DefaultErrorEncoder(_ context.Context, err error, reply string, nc *nats.Conn) { logger := log.NewNopLogger() type Response struct { Error string `json:"err"` } var response Response response.Error = err.Error() b, err := json.Marshal(response) if err != nil { logger.Log("err", err) return } if...
[ "func", "DefaultErrorEncoder", "(", "_", "context", ".", "Context", ",", "err", "error", ",", "reply", "string", ",", "nc", "*", "nats", ".", "Conn", ")", "{", "logger", ":=", "log", ".", "NewNopLogger", "(", ")", "\n\n", "type", "Response", "struct", ...
// DefaultErrorEncoder writes the error to the subscriber reply.
[ "DefaultErrorEncoder", "writes", "the", "error", "to", "the", "subscriber", "reply", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/nats/subscriber.go#L177-L197
126,813
go-kit/kit
transport/amqp/publisher.go
PublisherBefore
func PublisherBefore(before ...RequestFunc) PublisherOption { return func(p *Publisher) { p.before = append(p.before, before...) } }
go
func PublisherBefore(before ...RequestFunc) PublisherOption { return func(p *Publisher) { p.before = append(p.before, before...) } }
[ "func", "PublisherBefore", "(", "before", "...", "RequestFunc", ")", "PublisherOption", "{", "return", "func", "(", "p", "*", "Publisher", ")", "{", "p", ".", "before", "=", "append", "(", "p", ".", "before", ",", "before", "...", ")", "}", "\n", "}" ]
// PublisherBefore sets the RequestFuncs that are applied to the outgoing AMQP // request before it's invoked.
[ "PublisherBefore", "sets", "the", "RequestFuncs", "that", "are", "applied", "to", "the", "outgoing", "AMQP", "request", "before", "it", "s", "invoked", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/amqp/publisher.go#L55-L57
126,814
go-kit/kit
transport/amqp/publisher.go
PublisherAfter
func PublisherAfter(after ...PublisherResponseFunc) PublisherOption { return func(p *Publisher) { p.after = append(p.after, after...) } }
go
func PublisherAfter(after ...PublisherResponseFunc) PublisherOption { return func(p *Publisher) { p.after = append(p.after, after...) } }
[ "func", "PublisherAfter", "(", "after", "...", "PublisherResponseFunc", ")", "PublisherOption", "{", "return", "func", "(", "p", "*", "Publisher", ")", "{", "p", ".", "after", "=", "append", "(", "p", ".", "after", ",", "after", "...", ")", "}", "\n", ...
// PublisherAfter sets the ClientResponseFuncs applied to the incoming AMQP // request prior to it being decoded. This is useful for obtaining anything off // of the response and adding onto the context prior to decoding.
[ "PublisherAfter", "sets", "the", "ClientResponseFuncs", "applied", "to", "the", "incoming", "AMQP", "request", "prior", "to", "it", "being", "decoded", ".", "This", "is", "useful", "for", "obtaining", "anything", "off", "of", "the", "response", "and", "adding", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/amqp/publisher.go#L62-L64
126,815
go-kit/kit
transport/amqp/publisher.go
PublisherTimeout
func PublisherTimeout(timeout time.Duration) PublisherOption { return func(p *Publisher) { p.timeout = timeout } }
go
func PublisherTimeout(timeout time.Duration) PublisherOption { return func(p *Publisher) { p.timeout = timeout } }
[ "func", "PublisherTimeout", "(", "timeout", "time", ".", "Duration", ")", "PublisherOption", "{", "return", "func", "(", "p", "*", "Publisher", ")", "{", "p", ".", "timeout", "=", "timeout", "}", "\n", "}" ]
// PublisherTimeout sets the available timeout for an AMQP request.
[ "PublisherTimeout", "sets", "the", "available", "timeout", "for", "an", "AMQP", "request", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/amqp/publisher.go#L72-L74
126,816
go-kit/kit
transport/amqp/publisher.go
DefaultDeliverer
func DefaultDeliverer( ctx context.Context, p Publisher, pub *amqp.Publishing, ) (*amqp.Delivery, error) { err := p.ch.Publish( getPublishExchange(ctx), getPublishKey(ctx), false, //mandatory false, //immediate *pub, ) if err != nil { return nil, err } autoAck := getConsumeAutoAck(ctx) msg, err :=...
go
func DefaultDeliverer( ctx context.Context, p Publisher, pub *amqp.Publishing, ) (*amqp.Delivery, error) { err := p.ch.Publish( getPublishExchange(ctx), getPublishKey(ctx), false, //mandatory false, //immediate *pub, ) if err != nil { return nil, err } autoAck := getConsumeAutoAck(ctx) msg, err :=...
[ "func", "DefaultDeliverer", "(", "ctx", "context", ".", "Context", ",", "p", "Publisher", ",", "pub", "*", "amqp", ".", "Publishing", ",", ")", "(", "*", "amqp", ".", "Delivery", ",", "error", ")", "{", "err", ":=", "p", ".", "ch", ".", "Publish", ...
// DefaultDeliverer is a deliverer that publishes the specified Publishing // and returns the first Delivery object with the matching correlationId. // If the context times out while waiting for a reply, an error will be returned.
[ "DefaultDeliverer", "is", "a", "deliverer", "that", "publishes", "the", "specified", "Publishing", "and", "returns", "the", "first", "Delivery", "object", "with", "the", "matching", "correlationId", ".", "If", "the", "context", "times", "out", "while", "waiting", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/amqp/publisher.go#L124-L169
126,817
go-kit/kit
transport/amqp/publisher.go
SendAndForgetDeliverer
func SendAndForgetDeliverer( ctx context.Context, p Publisher, pub *amqp.Publishing, ) (*amqp.Delivery, error) { err := p.ch.Publish( getPublishExchange(ctx), getPublishKey(ctx), false, //mandatory false, //immediate *pub, ) return nil, err }
go
func SendAndForgetDeliverer( ctx context.Context, p Publisher, pub *amqp.Publishing, ) (*amqp.Delivery, error) { err := p.ch.Publish( getPublishExchange(ctx), getPublishKey(ctx), false, //mandatory false, //immediate *pub, ) return nil, err }
[ "func", "SendAndForgetDeliverer", "(", "ctx", "context", ".", "Context", ",", "p", "Publisher", ",", "pub", "*", "amqp", ".", "Publishing", ",", ")", "(", "*", "amqp", ".", "Delivery", ",", "error", ")", "{", "err", ":=", "p", ".", "ch", ".", "Publis...
// SendAndForgetDeliverer delivers the supplied publishing and // returns a nil response. // When using this deliverer please ensure that the supplied DecodeResponseFunc and // PublisherResponseFunc are able to handle nil-type responses.
[ "SendAndForgetDeliverer", "delivers", "the", "supplied", "publishing", "and", "returns", "a", "nil", "response", ".", "When", "using", "this", "deliverer", "please", "ensure", "that", "the", "supplied", "DecodeResponseFunc", "and", "PublisherResponseFunc", "are", "abl...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/amqp/publisher.go#L175-L188
126,818
go-kit/kit
examples/shipping/cargo/delivery.go
UpdateOnRouting
func (d Delivery) UpdateOnRouting(rs RouteSpecification, itinerary Itinerary) Delivery { return newDelivery(d.LastEvent, itinerary, rs) }
go
func (d Delivery) UpdateOnRouting(rs RouteSpecification, itinerary Itinerary) Delivery { return newDelivery(d.LastEvent, itinerary, rs) }
[ "func", "(", "d", "Delivery", ")", "UpdateOnRouting", "(", "rs", "RouteSpecification", ",", "itinerary", "Itinerary", ")", "Delivery", "{", "return", "newDelivery", "(", "d", ".", "LastEvent", ",", "itinerary", ",", "rs", ")", "\n", "}" ]
// UpdateOnRouting creates a new delivery snapshot to reflect changes in // routing, i.e. when the route specification or the itinerary has changed but // no additional handling of the cargo has been performed.
[ "UpdateOnRouting", "creates", "a", "new", "delivery", "snapshot", "to", "reflect", "changes", "in", "routing", "i", ".", "e", ".", "when", "the", "route", "specification", "or", "the", "itinerary", "has", "changed", "but", "no", "additional", "handling", "of",...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/delivery.go#L29-L31
126,819
go-kit/kit
examples/shipping/cargo/delivery.go
DeriveDeliveryFrom
func DeriveDeliveryFrom(rs RouteSpecification, itinerary Itinerary, history HandlingHistory) Delivery { lastEvent, _ := history.MostRecentlyCompletedEvent() return newDelivery(lastEvent, itinerary, rs) }
go
func DeriveDeliveryFrom(rs RouteSpecification, itinerary Itinerary, history HandlingHistory) Delivery { lastEvent, _ := history.MostRecentlyCompletedEvent() return newDelivery(lastEvent, itinerary, rs) }
[ "func", "DeriveDeliveryFrom", "(", "rs", "RouteSpecification", ",", "itinerary", "Itinerary", ",", "history", "HandlingHistory", ")", "Delivery", "{", "lastEvent", ",", "_", ":=", "history", ".", "MostRecentlyCompletedEvent", "(", ")", "\n", "return", "newDelivery",...
// DeriveDeliveryFrom creates a new delivery snapshot based on the complete // handling history of a cargo, as well as its route specification and // itinerary.
[ "DeriveDeliveryFrom", "creates", "a", "new", "delivery", "snapshot", "based", "on", "the", "complete", "handling", "history", "of", "a", "cargo", "as", "well", "as", "its", "route", "specification", "and", "itinerary", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/delivery.go#L41-L44
126,820
go-kit/kit
examples/shipping/cargo/delivery.go
newDelivery
func newDelivery(lastEvent HandlingEvent, itinerary Itinerary, rs RouteSpecification) Delivery { var ( routingStatus = calculateRoutingStatus(itinerary, rs) transportStatus = calculateTransportStatus(lastEvent) lastKnownLocation = calculateLastKnownLocation(lastEvent) isMisdirected ...
go
func newDelivery(lastEvent HandlingEvent, itinerary Itinerary, rs RouteSpecification) Delivery { var ( routingStatus = calculateRoutingStatus(itinerary, rs) transportStatus = calculateTransportStatus(lastEvent) lastKnownLocation = calculateLastKnownLocation(lastEvent) isMisdirected ...
[ "func", "newDelivery", "(", "lastEvent", "HandlingEvent", ",", "itinerary", "Itinerary", ",", "rs", "RouteSpecification", ")", "Delivery", "{", "var", "(", "routingStatus", "=", "calculateRoutingStatus", "(", "itinerary", ",", "rs", ")", "\n", "transportStatus", "...
// newDelivery creates a up-to-date delivery based on an handling event, // itinerary and a route specification.
[ "newDelivery", "creates", "a", "up", "-", "to", "-", "date", "delivery", "based", "on", "an", "handling", "event", "itinerary", "and", "a", "route", "specification", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/delivery.go#L48-L74
126,821
go-kit/kit
examples/shipping/cargo/delivery.go
calculateRoutingStatus
func calculateRoutingStatus(itinerary Itinerary, rs RouteSpecification) RoutingStatus { if itinerary.Legs == nil { return NotRouted } if rs.IsSatisfiedBy(itinerary) { return Routed } return Misrouted }
go
func calculateRoutingStatus(itinerary Itinerary, rs RouteSpecification) RoutingStatus { if itinerary.Legs == nil { return NotRouted } if rs.IsSatisfiedBy(itinerary) { return Routed } return Misrouted }
[ "func", "calculateRoutingStatus", "(", "itinerary", "Itinerary", ",", "rs", "RouteSpecification", ")", "RoutingStatus", "{", "if", "itinerary", ".", "Legs", "==", "nil", "{", "return", "NotRouted", "\n", "}", "\n\n", "if", "rs", ".", "IsSatisfiedBy", "(", "iti...
// Below are internal functions used when creating a new delivery.
[ "Below", "are", "internal", "functions", "used", "when", "creating", "a", "new", "delivery", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/cargo/delivery.go#L78-L88
126,822
go-kit/kit
sd/etcdv3/client.go
NewClient
func NewClient(ctx context.Context, machines []string, options ClientOptions) (Client, error) { if options.DialTimeout == 0 { options.DialTimeout = 3 * time.Second } if options.DialKeepAlive == 0 { options.DialKeepAlive = 3 * time.Second } var err error var tlscfg *tls.Config if options.Cert != "" && optio...
go
func NewClient(ctx context.Context, machines []string, options ClientOptions) (Client, error) { if options.DialTimeout == 0 { options.DialTimeout = 3 * time.Second } if options.DialKeepAlive == 0 { options.DialKeepAlive = 3 * time.Second } var err error var tlscfg *tls.Config if options.Cert != "" && optio...
[ "func", "NewClient", "(", "ctx", "context", ".", "Context", ",", "machines", "[", "]", "string", ",", "options", "ClientOptions", ")", "(", "Client", ",", "error", ")", "{", "if", "options", ".", "DialTimeout", "==", "0", "{", "options", ".", "DialTimeou...
// NewClient returns Client with a connection to the named machines. It will // return an error if a connection to the cluster cannot be made.
[ "NewClient", "returns", "Client", "with", "a", "connection", "to", "the", "named", "machines", ".", "It", "will", "return", "an", "error", "if", "a", "connection", "to", "the", "cluster", "cannot", "be", "made", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/etcdv3/client.go#L82-L123
126,823
go-kit/kit
sd/etcdv3/client.go
close
func (c *client) close() { if c.leaser != nil { c.leaser.Close() } if c.watcher != nil { c.watcher.Close() } if c.wcf != nil { c.wcf() } }
go
func (c *client) close() { if c.leaser != nil { c.leaser.Close() } if c.watcher != nil { c.watcher.Close() } if c.wcf != nil { c.wcf() } }
[ "func", "(", "c", "*", "client", ")", "close", "(", ")", "{", "if", "c", ".", "leaser", "!=", "nil", "{", "c", ".", "leaser", ".", "Close", "(", ")", "\n", "}", "\n", "if", "c", ".", "watcher", "!=", "nil", "{", "c", ".", "watcher", ".", "C...
// close will close any open clients and call // the watcher cancel func
[ "close", "will", "close", "any", "open", "clients", "and", "call", "the", "watcher", "cancel", "func" ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/etcdv3/client.go#L241-L251
126,824
go-kit/kit
sd/endpoint_cache.go
newEndpointCache
func newEndpointCache(factory Factory, logger log.Logger, options endpointerOptions) *endpointCache { return &endpointCache{ options: options, factory: factory, cache: map[string]endpointCloser{}, logger: logger, timeNow: time.Now, } }
go
func newEndpointCache(factory Factory, logger log.Logger, options endpointerOptions) *endpointCache { return &endpointCache{ options: options, factory: factory, cache: map[string]endpointCloser{}, logger: logger, timeNow: time.Now, } }
[ "func", "newEndpointCache", "(", "factory", "Factory", ",", "logger", "log", ".", "Logger", ",", "options", "endpointerOptions", ")", "*", "endpointCache", "{", "return", "&", "endpointCache", "{", "options", ":", "options", ",", "factory", ":", "factory", ","...
// newEndpointCache returns a new, empty endpointCache.
[ "newEndpointCache", "returns", "a", "new", "empty", "endpointCache", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/endpoint_cache.go#L34-L42
126,825
go-kit/kit
sd/endpoint_cache.go
Update
func (c *endpointCache) Update(event Event) { c.mtx.Lock() defer c.mtx.Unlock() // Happy path. if event.Err == nil { c.updateCache(event.Instances) c.err = nil return } // Sad path. Something's gone wrong in sd. c.logger.Log("err", event.Err) if !c.options.invalidateOnError { return // keep returning ...
go
func (c *endpointCache) Update(event Event) { c.mtx.Lock() defer c.mtx.Unlock() // Happy path. if event.Err == nil { c.updateCache(event.Instances) c.err = nil return } // Sad path. Something's gone wrong in sd. c.logger.Log("err", event.Err) if !c.options.invalidateOnError { return // keep returning ...
[ "func", "(", "c", "*", "endpointCache", ")", "Update", "(", "event", "Event", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// Happy path.", "if", "event", ".", "Err", "==", "n...
// Update should be invoked by clients with a complete set of current instance // strings whenever that set changes. The cache manufactures new endpoints via // the factory, closes old endpoints when they disappear, and persists existing // endpoints if they survive through an update.
[ "Update", "should", "be", "invoked", "by", "clients", "with", "a", "complete", "set", "of", "current", "instance", "strings", "whenever", "that", "set", "changes", ".", "The", "cache", "manufactures", "new", "endpoints", "via", "the", "factory", "closes", "old...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/endpoint_cache.go#L48-L71
126,826
go-kit/kit
metrics/provider/dogstatsd.go
NewDogstatsdProvider
func NewDogstatsdProvider(d *dogstatsd.Dogstatsd, stop func()) Provider { return &dogstatsdProvider{ d: d, stop: stop, } }
go
func NewDogstatsdProvider(d *dogstatsd.Dogstatsd, stop func()) Provider { return &dogstatsdProvider{ d: d, stop: stop, } }
[ "func", "NewDogstatsdProvider", "(", "d", "*", "dogstatsd", ".", "Dogstatsd", ",", "stop", "func", "(", ")", ")", "Provider", "{", "return", "&", "dogstatsdProvider", "{", "d", ":", "d", ",", "stop", ":", "stop", ",", "}", "\n", "}" ]
// NewDogstatsdProvider wraps the given Dogstatsd object and stop func and // returns a Provider that produces Dogstatsd metrics. A typical stop function // would be ticker.Stop from the ticker passed to the SendLoop helper method.
[ "NewDogstatsdProvider", "wraps", "the", "given", "Dogstatsd", "object", "and", "stop", "func", "and", "returns", "a", "Provider", "that", "produces", "Dogstatsd", "metrics", ".", "A", "typical", "stop", "function", "would", "be", "ticker", ".", "Stop", "from", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/provider/dogstatsd.go#L16-L21
126,827
go-kit/kit
metrics/provider/dogstatsd.go
NewCounter
func (p *dogstatsdProvider) NewCounter(name string) metrics.Counter { return p.d.NewCounter(name, 1.0) }
go
func (p *dogstatsdProvider) NewCounter(name string) metrics.Counter { return p.d.NewCounter(name, 1.0) }
[ "func", "(", "p", "*", "dogstatsdProvider", ")", "NewCounter", "(", "name", "string", ")", "metrics", ".", "Counter", "{", "return", "p", ".", "d", ".", "NewCounter", "(", "name", ",", "1.0", ")", "\n", "}" ]
// NewCounter implements Provider, returning a new Dogstatsd Counter with a // sample rate of 1.0.
[ "NewCounter", "implements", "Provider", "returning", "a", "new", "Dogstatsd", "Counter", "with", "a", "sample", "rate", "of", "1", ".", "0", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/provider/dogstatsd.go#L25-L27
126,828
go-kit/kit
metrics/expvar/expvar.go
NewHistogram
func NewHistogram(name string, buckets int) *Histogram { return &Histogram{ h: generic.NewHistogram(name, buckets), p50: expvar.NewFloat(name + ".p50"), p90: expvar.NewFloat(name + ".p90"), p95: expvar.NewFloat(name + ".p95"), p99: expvar.NewFloat(name + ".p99"), } }
go
func NewHistogram(name string, buckets int) *Histogram { return &Histogram{ h: generic.NewHistogram(name, buckets), p50: expvar.NewFloat(name + ".p50"), p90: expvar.NewFloat(name + ".p90"), p95: expvar.NewFloat(name + ".p95"), p99: expvar.NewFloat(name + ".p99"), } }
[ "func", "NewHistogram", "(", "name", "string", ",", "buckets", "int", ")", "*", "Histogram", "{", "return", "&", "Histogram", "{", "h", ":", "generic", ".", "NewHistogram", "(", "name", ",", "buckets", ")", ",", "p50", ":", "expvar", ".", "NewFloat", "...
// NewHistogram returns a Histogram object with the given name and number of // buckets in the underlying histogram object. 50 is a good default number of // buckets.
[ "NewHistogram", "returns", "a", "Histogram", "object", "with", "the", "given", "name", "and", "number", "of", "buckets", "in", "the", "underlying", "histogram", "object", ".", "50", "is", "a", "good", "default", "number", "of", "buckets", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/expvar/expvar.go#L72-L80
126,829
go-kit/kit
transport/http/jsonrpc/client.go
DefaultRequestEncoder
func DefaultRequestEncoder(_ context.Context, req interface{}) (json.RawMessage, error) { return json.Marshal(req) }
go
func DefaultRequestEncoder(_ context.Context, req interface{}) (json.RawMessage, error) { return json.Marshal(req) }
[ "func", "DefaultRequestEncoder", "(", "_", "context", ".", "Context", ",", "req", "interface", "{", "}", ")", "(", "json", ".", "RawMessage", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "req", ")", "\n", "}" ]
// DefaultRequestEncoder marshals the given request to JSON.
[ "DefaultRequestEncoder", "marshals", "the", "given", "request", "to", "JSON", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/jsonrpc/client.go#L66-L68
126,830
go-kit/kit
transport/http/jsonrpc/client.go
SetClient
func SetClient(client httptransport.HTTPClient) ClientOption { return func(c *Client) { c.client = client } }
go
func SetClient(client httptransport.HTTPClient) ClientOption { return func(c *Client) { c.client = client } }
[ "func", "SetClient", "(", "client", "httptransport", ".", "HTTPClient", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "client", "=", "client", "}", "\n", "}" ]
// SetClient sets the underlying HTTP client used for requests. // By default, http.DefaultClient is used.
[ "SetClient", "sets", "the", "underlying", "HTTP", "client", "used", "for", "requests", ".", "By", "default", "http", ".", "DefaultClient", "is", "used", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/jsonrpc/client.go#L89-L91
126,831
go-kit/kit
transport/http/jsonrpc/client.go
ClientBefore
func ClientBefore(before ...httptransport.RequestFunc) ClientOption { return func(c *Client) { c.before = append(c.before, before...) } }
go
func ClientBefore(before ...httptransport.RequestFunc) ClientOption { return func(c *Client) { c.before = append(c.before, before...) } }
[ "func", "ClientBefore", "(", "before", "...", "httptransport", ".", "RequestFunc", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "before", "=", "append", "(", "c", ".", "before", ",", "before", "...", ")", "}"...
// ClientBefore sets the RequestFuncs that are applied to the outgoing HTTP // request before it's invoked.
[ "ClientBefore", "sets", "the", "RequestFuncs", "that", "are", "applied", "to", "the", "outgoing", "HTTP", "request", "before", "it", "s", "invoked", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/jsonrpc/client.go#L95-L97
126,832
go-kit/kit
transport/http/jsonrpc/client.go
ClientFinalizer
func ClientFinalizer(f httptransport.ClientFinalizerFunc) ClientOption { return func(c *Client) { c.finalizer = f } }
go
func ClientFinalizer(f httptransport.ClientFinalizerFunc) ClientOption { return func(c *Client) { c.finalizer = f } }
[ "func", "ClientFinalizer", "(", "f", "httptransport", ".", "ClientFinalizerFunc", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "finalizer", "=", "f", "}", "\n", "}" ]
// ClientFinalizer is executed at the end of every HTTP request. // By default, no finalizer is registered.
[ "ClientFinalizer", "is", "executed", "at", "the", "end", "of", "every", "HTTP", "request", ".", "By", "default", "no", "finalizer", "is", "registered", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/jsonrpc/client.go#L108-L110
126,833
go-kit/kit
metrics/internal/lv/labelvalues.go
With
func (lvs LabelValues) With(labelValues ...string) LabelValues { if len(labelValues)%2 != 0 { labelValues = append(labelValues, "unknown") } return append(lvs, labelValues...) }
go
func (lvs LabelValues) With(labelValues ...string) LabelValues { if len(labelValues)%2 != 0 { labelValues = append(labelValues, "unknown") } return append(lvs, labelValues...) }
[ "func", "(", "lvs", "LabelValues", ")", "With", "(", "labelValues", "...", "string", ")", "LabelValues", "{", "if", "len", "(", "labelValues", ")", "%", "2", "!=", "0", "{", "labelValues", "=", "append", "(", "labelValues", ",", "\"", "\"", ")", "\n", ...
// With validates the input, and returns a new aggregate labelValues.
[ "With", "validates", "the", "input", "and", "returns", "a", "new", "aggregate", "labelValues", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/internal/lv/labelvalues.go#L9-L14
126,834
go-kit/kit
examples/shipping/inspection/inspection.go
NewService
func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository, handler EventHandler) Service { return &service{cargos, events, handler} }
go
func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository, handler EventHandler) Service { return &service{cargos, events, handler} }
[ "func", "NewService", "(", "cargos", "cargo", ".", "Repository", ",", "events", "cargo", ".", "HandlingEventRepository", ",", "handler", "EventHandler", ")", "Service", "{", "return", "&", "service", "{", "cargos", ",", "events", ",", "handler", "}", "\n", "...
// NewService creates a inspection service with necessary dependencies.
[ "NewService", "creates", "a", "inspection", "service", "with", "necessary", "dependencies", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/inspection/inspection.go#L51-L53
126,835
go-kit/kit
log/sync.go
Log
func (l *SwapLogger) Log(keyvals ...interface{}) error { s, ok := l.logger.Load().(loggerStruct) if !ok || s.Logger == nil { return nil } return s.Log(keyvals...) }
go
func (l *SwapLogger) Log(keyvals ...interface{}) error { s, ok := l.logger.Load().(loggerStruct) if !ok || s.Logger == nil { return nil } return s.Log(keyvals...) }
[ "func", "(", "l", "*", "SwapLogger", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "error", "{", "s", ",", "ok", ":=", "l", ".", "logger", ".", "Load", "(", ")", ".", "(", "loggerStruct", ")", "\n", "if", "!", "ok", "||", "s", ...
// Log implements the Logger interface by forwarding keyvals to the currently // wrapped logger. It does not log anything if the wrapped logger is nil.
[ "Log", "implements", "the", "Logger", "interface", "by", "forwarding", "keyvals", "to", "the", "currently", "wrapped", "logger", ".", "It", "does", "not", "log", "anything", "if", "the", "wrapped", "logger", "is", "nil", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/sync.go#L25-L31
126,836
go-kit/kit
log/sync.go
Swap
func (l *SwapLogger) Swap(logger Logger) { l.logger.Store(loggerStruct{logger}) }
go
func (l *SwapLogger) Swap(logger Logger) { l.logger.Store(loggerStruct{logger}) }
[ "func", "(", "l", "*", "SwapLogger", ")", "Swap", "(", "logger", "Logger", ")", "{", "l", ".", "logger", ".", "Store", "(", "loggerStruct", "{", "logger", "}", ")", "\n", "}" ]
// Swap replaces the currently wrapped logger with logger. Swap may be called // concurrently with calls to Log from other goroutines.
[ "Swap", "replaces", "the", "currently", "wrapped", "logger", "with", "logger", ".", "Swap", "may", "be", "called", "concurrently", "with", "calls", "to", "Log", "from", "other", "goroutines", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/sync.go#L35-L37
126,837
go-kit/kit
log/sync.go
Write
func (w *syncWriter) Write(p []byte) (n int, err error) { w.Lock() n, err = w.Writer.Write(p) w.Unlock() return n, err }
go
func (w *syncWriter) Write(p []byte) (n int, err error) { w.Lock() n, err = w.Writer.Write(p) w.Unlock() return n, err }
[ "func", "(", "w", "*", "syncWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "w", ".", "Lock", "(", ")", "\n", "n", ",", "err", "=", "w", ".", "Writer", ".", "Write", "(", "p", ")", "...
// Write writes p to the underlying io.Writer. If another write is already in // progress, the calling goroutine blocks until the syncWriter is available.
[ "Write", "writes", "p", "to", "the", "underlying", "io", ".", "Writer", ".", "If", "another", "write", "is", "already", "in", "progress", "the", "calling", "goroutine", "blocks", "until", "the", "syncWriter", "is", "available", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/sync.go#L66-L71
126,838
go-kit/kit
log/sync.go
Write
func (w *fdSyncWriter) Write(p []byte) (n int, err error) { w.Lock() n, err = w.fdWriter.Write(p) w.Unlock() return n, err }
go
func (w *fdSyncWriter) Write(p []byte) (n int, err error) { w.Lock() n, err = w.fdWriter.Write(p) w.Unlock() return n, err }
[ "func", "(", "w", "*", "fdSyncWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "w", ".", "Lock", "(", ")", "\n", "n", ",", "err", "=", "w", ".", "fdWriter", ".", "Write", "(", "p", ")",...
// Write writes p to the underlying io.Writer. If another write is already in // progress, the calling goroutine blocks until the fdSyncWriter is available.
[ "Write", "writes", "p", "to", "the", "underlying", "io", ".", "Writer", ".", "If", "another", "write", "is", "already", "in", "progress", "the", "calling", "goroutine", "blocks", "until", "the", "fdSyncWriter", "is", "available", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/sync.go#L88-L93
126,839
go-kit/kit
log/sync.go
Log
func (l *syncLogger) Log(keyvals ...interface{}) error { l.mu.Lock() err := l.logger.Log(keyvals...) l.mu.Unlock() return err }
go
func (l *syncLogger) Log(keyvals ...interface{}) error { l.mu.Lock() err := l.logger.Log(keyvals...) l.mu.Unlock() return err }
[ "func", "(", "l", "*", "syncLogger", ")", "Log", "(", "keyvals", "...", "interface", "{", "}", ")", "error", "{", "l", ".", "mu", ".", "Lock", "(", ")", "\n", "err", ":=", "l", ".", "logger", ".", "Log", "(", "keyvals", "...", ")", "\n", "l", ...
// Log logs keyvals to the underlying Logger. If another log is already in // progress, the calling goroutine blocks until the syncLogger is available.
[ "Log", "logs", "keyvals", "to", "the", "underlying", "Logger", ".", "If", "another", "log", "is", "already", "in", "progress", "the", "calling", "goroutine", "blocks", "until", "the", "syncLogger", "is", "available", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/sync.go#L111-L116
126,840
go-kit/kit
transport/grpc/request_response_funcs.go
SetRequestHeader
func SetRequestHeader(key, val string) ClientRequestFunc { return func(ctx context.Context, md *metadata.MD) context.Context { key, val := EncodeKeyValue(key, val) (*md)[key] = append((*md)[key], val) return ctx } }
go
func SetRequestHeader(key, val string) ClientRequestFunc { return func(ctx context.Context, md *metadata.MD) context.Context { key, val := EncodeKeyValue(key, val) (*md)[key] = append((*md)[key], val) return ctx } }
[ "func", "SetRequestHeader", "(", "key", ",", "val", "string", ")", "ClientRequestFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "md", "*", "metadata", ".", "MD", ")", "context", ".", "Context", "{", "key", ",", "val", ":=", "...
// SetRequestHeader returns a ClientRequestFunc that sets the specified metadata // key-value pair.
[ "SetRequestHeader", "returns", "a", "ClientRequestFunc", "that", "sets", "the", "specified", "metadata", "key", "-", "value", "pair", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/request_response_funcs.go#L40-L46
126,841
go-kit/kit
transport/grpc/request_response_funcs.go
SetResponseHeader
func SetResponseHeader(key, val string) ServerResponseFunc { return func(ctx context.Context, md *metadata.MD, _ *metadata.MD) context.Context { key, val := EncodeKeyValue(key, val) (*md)[key] = append((*md)[key], val) return ctx } }
go
func SetResponseHeader(key, val string) ServerResponseFunc { return func(ctx context.Context, md *metadata.MD, _ *metadata.MD) context.Context { key, val := EncodeKeyValue(key, val) (*md)[key] = append((*md)[key], val) return ctx } }
[ "func", "SetResponseHeader", "(", "key", ",", "val", "string", ")", "ServerResponseFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "md", "*", "metadata", ".", "MD", ",", "_", "*", "metadata", ".", "MD", ")", "context", ".", "C...
// SetResponseHeader returns a ResponseFunc that sets the specified metadata // key-value pair.
[ "SetResponseHeader", "returns", "a", "ResponseFunc", "that", "sets", "the", "specified", "metadata", "key", "-", "value", "pair", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/request_response_funcs.go#L50-L56
126,842
go-kit/kit
transport/grpc/request_response_funcs.go
EncodeKeyValue
func EncodeKeyValue(key, val string) (string, string) { key = strings.ToLower(key) if strings.HasSuffix(key, binHdrSuffix) { val = base64.StdEncoding.EncodeToString([]byte(val)) } return key, val }
go
func EncodeKeyValue(key, val string) (string, string) { key = strings.ToLower(key) if strings.HasSuffix(key, binHdrSuffix) { val = base64.StdEncoding.EncodeToString([]byte(val)) } return key, val }
[ "func", "EncodeKeyValue", "(", "key", ",", "val", "string", ")", "(", "string", ",", "string", ")", "{", "key", "=", "strings", ".", "ToLower", "(", "key", ")", "\n", "if", "strings", ".", "HasSuffix", "(", "key", ",", "binHdrSuffix", ")", "{", "val"...
// EncodeKeyValue sanitizes a key-value pair for use in gRPC metadata headers.
[ "EncodeKeyValue", "sanitizes", "a", "key", "-", "value", "pair", "for", "use", "in", "gRPC", "metadata", "headers", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/request_response_funcs.go#L69-L75
126,843
go-kit/kit
transport/grpc/client.go
NewClient
func NewClient( cc *grpc.ClientConn, serviceName string, method string, enc EncodeRequestFunc, dec DecodeResponseFunc, grpcReply interface{}, options ...ClientOption, ) *Client { c := &Client{ client: cc, method: fmt.Sprintf("/%s/%s", serviceName, method), enc: enc, dec: dec, // We are using ref...
go
func NewClient( cc *grpc.ClientConn, serviceName string, method string, enc EncodeRequestFunc, dec DecodeResponseFunc, grpcReply interface{}, options ...ClientOption, ) *Client { c := &Client{ client: cc, method: fmt.Sprintf("/%s/%s", serviceName, method), enc: enc, dec: dec, // We are using ref...
[ "func", "NewClient", "(", "cc", "*", "grpc", ".", "ClientConn", ",", "serviceName", "string", ",", "method", "string", ",", "enc", "EncodeRequestFunc", ",", "dec", "DecodeResponseFunc", ",", "grpcReply", "interface", "{", "}", ",", "options", "...", "ClientOpt...
// NewClient constructs a usable Client for a single remote endpoint. // Pass an zero-value protobuf message of the RPC response type as // the grpcReply argument.
[ "NewClient", "constructs", "a", "usable", "Client", "for", "a", "single", "remote", "endpoint", ".", "Pass", "an", "zero", "-", "value", "protobuf", "message", "of", "the", "RPC", "response", "type", "as", "the", "grpcReply", "argument", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/client.go#L31-L61
126,844
go-kit/kit
transport/grpc/client.go
ClientBefore
func ClientBefore(before ...ClientRequestFunc) ClientOption { return func(c *Client) { c.before = append(c.before, before...) } }
go
func ClientBefore(before ...ClientRequestFunc) ClientOption { return func(c *Client) { c.before = append(c.before, before...) } }
[ "func", "ClientBefore", "(", "before", "...", "ClientRequestFunc", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "before", "=", "append", "(", "c", ".", "before", ",", "before", "...", ")", "}", "\n", "}" ]
// ClientBefore sets the RequestFuncs that are applied to the outgoing gRPC // request before it's invoked.
[ "ClientBefore", "sets", "the", "RequestFuncs", "that", "are", "applied", "to", "the", "outgoing", "gRPC", "request", "before", "it", "s", "invoked", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/client.go#L68-L70
126,845
go-kit/kit
transport/grpc/client.go
ClientAfter
func ClientAfter(after ...ClientResponseFunc) ClientOption { return func(c *Client) { c.after = append(c.after, after...) } }
go
func ClientAfter(after ...ClientResponseFunc) ClientOption { return func(c *Client) { c.after = append(c.after, after...) } }
[ "func", "ClientAfter", "(", "after", "...", "ClientResponseFunc", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "{", "c", ".", "after", "=", "append", "(", "c", ".", "after", ",", "after", "...", ")", "}", "\n", "}" ]
// ClientAfter sets the ClientResponseFuncs that are applied to the incoming // gRPC response prior to it being decoded. This is useful for obtaining // response metadata and adding onto the context prior to decoding.
[ "ClientAfter", "sets", "the", "ClientResponseFuncs", "that", "are", "applied", "to", "the", "incoming", "gRPC", "response", "prior", "to", "it", "being", "decoded", ".", "This", "is", "useful", "for", "obtaining", "response", "metadata", "and", "adding", "onto",...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/client.go#L75-L77
126,846
go-kit/kit
transport/grpc/client.go
ClientFinalizer
func ClientFinalizer(f ...ClientFinalizerFunc) ClientOption { return func(s *Client) { s.finalizer = append(s.finalizer, f...) } }
go
func ClientFinalizer(f ...ClientFinalizerFunc) ClientOption { return func(s *Client) { s.finalizer = append(s.finalizer, f...) } }
[ "func", "ClientFinalizer", "(", "f", "...", "ClientFinalizerFunc", ")", "ClientOption", "{", "return", "func", "(", "s", "*", "Client", ")", "{", "s", ".", "finalizer", "=", "append", "(", "s", ".", "finalizer", ",", "f", "...", ")", "}", "\n", "}" ]
// ClientFinalizer is executed at the end of every gRPC request. // By default, no finalizer is registered.
[ "ClientFinalizer", "is", "executed", "at", "the", "end", "of", "every", "gRPC", "request", ".", "By", "default", "no", "finalizer", "is", "registered", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/client.go#L81-L83
126,847
go-kit/kit
transport/grpc/client.go
Endpoint
func (c Client) Endpoint() endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() if c.finalizer != nil { defer func() { for _, f := range c.finalizer { f(ctx, err) } }() } ctx = ...
go
func (c Client) Endpoint() endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() if c.finalizer != nil { defer func() { for _, f := range c.finalizer { f(ctx, err) } }() } ctx = ...
[ "func", "(", "c", "Client", ")", "Endpoint", "(", ")", "endpoint", ".", "Endpoint", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "request", "interface", "{", "}", ")", "(", "response", "interface", "{", "}", ",", "err", "error", ...
// Endpoint returns a usable endpoint that will invoke the gRPC specified by the // client.
[ "Endpoint", "returns", "a", "usable", "endpoint", "that", "will", "invoke", "the", "gRPC", "specified", "by", "the", "client", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/grpc/client.go#L87-L132
126,848
go-kit/kit
log/syslog/syslog.go
NewSyslogLogger
func NewSyslogLogger(w SyslogWriter, newLogger func(io.Writer) log.Logger, options ...Option) log.Logger { l := &syslogLogger{ w: w, newLogger: newLogger, prioritySelector: defaultPrioritySelector, bufPool: sync.Pool{New: func() interface{} { return &loggerBuf{} }}, } for _, optio...
go
func NewSyslogLogger(w SyslogWriter, newLogger func(io.Writer) log.Logger, options ...Option) log.Logger { l := &syslogLogger{ w: w, newLogger: newLogger, prioritySelector: defaultPrioritySelector, bufPool: sync.Pool{New: func() interface{} { return &loggerBuf{} }}, } for _, optio...
[ "func", "NewSyslogLogger", "(", "w", "SyslogWriter", ",", "newLogger", "func", "(", "io", ".", "Writer", ")", "log", ".", "Logger", ",", "options", "...", "Option", ")", "log", ".", "Logger", "{", "l", ":=", "&", "syslogLogger", "{", "w", ":", "w", "...
// NewSyslogLogger returns a new Logger which writes to syslog in syslog format. // The body of the log message is the formatted output from the Logger returned // by newLogger.
[ "NewSyslogLogger", "returns", "a", "new", "Logger", "which", "writes", "to", "syslog", "in", "syslog", "format", ".", "The", "body", "of", "the", "log", "message", "is", "the", "formatted", "output", "from", "the", "Logger", "returned", "by", "newLogger", "....
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/syslog/syslog.go#L35-L50
126,849
go-kit/kit
tracing/opentracing/endpoint.go
TraceServer
func TraceServer(tracer opentracing.Tracer, operationName string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { serverSpan := opentracing.SpanFromContext(ctx) if serverSpan == nil { // All we can do...
go
func TraceServer(tracer opentracing.Tracer, operationName string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { serverSpan := opentracing.SpanFromContext(ctx) if serverSpan == nil { // All we can do...
[ "func", "TraceServer", "(", "tracer", "opentracing", ".", "Tracer", ",", "operationName", "string", ")", "endpoint", ".", "Middleware", "{", "return", "func", "(", "next", "endpoint", ".", "Endpoint", ")", "endpoint", ".", "Endpoint", "{", "return", "func", ...
// TraceServer returns a Middleware that wraps the `next` Endpoint in an // OpenTracing Span called `operationName`. // // If `ctx` already has a Span, it is re-used and the operation name is // overwritten. If `ctx` does not yet have a Span, one is created here.
[ "TraceServer", "returns", "a", "Middleware", "that", "wraps", "the", "next", "Endpoint", "in", "an", "OpenTracing", "Span", "called", "operationName", ".", "If", "ctx", "already", "has", "a", "Span", "it", "is", "re", "-", "used", "and", "the", "operation", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opentracing/endpoint.go#L17-L33
126,850
go-kit/kit
tracing/opentracing/endpoint.go
TraceClient
func TraceClient(tracer opentracing.Tracer, operationName string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { var clientSpan opentracing.Span if parentSpan := opentracing.SpanFromContext(ctx); parentS...
go
func TraceClient(tracer opentracing.Tracer, operationName string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { var clientSpan opentracing.Span if parentSpan := opentracing.SpanFromContext(ctx); parentS...
[ "func", "TraceClient", "(", "tracer", "opentracing", ".", "Tracer", ",", "operationName", "string", ")", "endpoint", ".", "Middleware", "{", "return", "func", "(", "next", "endpoint", ".", "Endpoint", ")", "endpoint", ".", "Endpoint", "{", "return", "func", ...
// TraceClient returns a Middleware that wraps the `next` Endpoint in an // OpenTracing Span called `operationName`.
[ "TraceClient", "returns", "a", "Middleware", "that", "wraps", "the", "next", "Endpoint", "in", "an", "OpenTracing", "Span", "called", "operationName", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opentracing/endpoint.go#L37-L55
126,851
go-kit/kit
examples/addsvc/pkg/addtransport/thrift.go
NewThriftClient
func NewThriftClient(client *addthrift.AddServiceClient) addservice.Service { // We construct a single ratelimiter middleware, to limit the total outgoing // QPS from this client to all methods on the remote instance. We also // construct per-endpoint circuitbreaker middlewares to demonstrate how // that's done, al...
go
func NewThriftClient(client *addthrift.AddServiceClient) addservice.Service { // We construct a single ratelimiter middleware, to limit the total outgoing // QPS from this client to all methods on the remote instance. We also // construct per-endpoint circuitbreaker middlewares to demonstrate how // that's done, al...
[ "func", "NewThriftClient", "(", "client", "*", "addthrift", ".", "AddServiceClient", ")", "addservice", ".", "Service", "{", "// We construct a single ratelimiter middleware, to limit the total outgoing", "// QPS from this client to all methods on the remote instance. We also", "// con...
// NewThriftClient returns an AddService backed by a Thrift server described by // the provided client. The caller is responsible for constructing the client, // and eventually closing the underlying transport. We bake-in certain middlewares, // implementing the client library pattern.
[ "NewThriftClient", "returns", "an", "AddService", "backed", "by", "a", "Thrift", "server", "described", "by", "the", "provided", "client", ".", "The", "caller", "is", "responsible", "for", "constructing", "the", "client", "and", "eventually", "closing", "the", "...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addtransport/thrift.go#L56-L96
126,852
go-kit/kit
tracing/opencensus/http.go
HTTPClientTrace
func HTTPClientTrace(options ...TracerOption) kithttp.ClientOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } if !cfg.Public && cfg.HTTPPropagate == nil { cfg.HTTPPropagate = &b3.HTTPFormat{} } clientBefore := kithttp.ClientBefore( func(ctx context.Context, req *http.Request...
go
func HTTPClientTrace(options ...TracerOption) kithttp.ClientOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } if !cfg.Public && cfg.HTTPPropagate == nil { cfg.HTTPPropagate = &b3.HTTPFormat{} } clientBefore := kithttp.ClientBefore( func(ctx context.Context, req *http.Request...
[ "func", "HTTPClientTrace", "(", "options", "...", "TracerOption", ")", "kithttp", ".", "ClientOption", "{", "cfg", ":=", "TracerOptions", "{", "}", "\n\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "cfg", ")", "\n", "}...
// HTTPClientTrace enables OpenCensus tracing of a Go kit HTTP transport client.
[ "HTTPClientTrace", "enables", "OpenCensus", "tracing", "of", "a", "Go", "kit", "HTTP", "transport", "client", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opencensus/http.go#L15-L90
126,853
go-kit/kit
tracing/opencensus/http.go
HTTPServerTrace
func HTTPServerTrace(options ...TracerOption) kithttp.ServerOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } if !cfg.Public && cfg.HTTPPropagate == nil { cfg.HTTPPropagate = &b3.HTTPFormat{} } serverBefore := kithttp.ServerBefore( func(ctx context.Context, req *http.Request...
go
func HTTPServerTrace(options ...TracerOption) kithttp.ServerOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } if !cfg.Public && cfg.HTTPPropagate == nil { cfg.HTTPPropagate = &b3.HTTPFormat{} } serverBefore := kithttp.ServerBefore( func(ctx context.Context, req *http.Request...
[ "func", "HTTPServerTrace", "(", "options", "...", "TracerOption", ")", "kithttp", ".", "ServerOption", "{", "cfg", ":=", "TracerOptions", "{", "}", "\n\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "cfg", ")", "\n", "}...
// HTTPServerTrace enables OpenCensus tracing of a Go kit HTTP transport server.
[ "HTTPServerTrace", "enables", "OpenCensus", "tracing", "of", "a", "Go", "kit", "HTTP", "transport", "server", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opencensus/http.go#L93-L174
126,854
go-kit/kit
sd/zk/logwrapper.go
withLogger
func withLogger(logger log.Logger) func(c *zk.Conn) { return func(c *zk.Conn) { c.SetLogger(wrapLogger{logger}) } }
go
func withLogger(logger log.Logger) func(c *zk.Conn) { return func(c *zk.Conn) { c.SetLogger(wrapLogger{logger}) } }
[ "func", "withLogger", "(", "logger", "log", ".", "Logger", ")", "func", "(", "c", "*", "zk", ".", "Conn", ")", "{", "return", "func", "(", "c", "*", "zk", ".", "Conn", ")", "{", "c", ".", "SetLogger", "(", "wrapLogger", "{", "logger", "}", ")", ...
// withLogger replaces the ZooKeeper library's default logging service with our // own Go kit logger.
[ "withLogger", "replaces", "the", "ZooKeeper", "library", "s", "default", "logging", "service", "with", "our", "own", "Go", "kit", "logger", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/logwrapper.go#L23-L27
126,855
go-kit/kit
examples/addsvc/pkg/addtransport/jsonrpc.go
makeEndpointCodecMap
func makeEndpointCodecMap(endpoints addendpoint.Set) jsonrpc.EndpointCodecMap { return jsonrpc.EndpointCodecMap{ "sum": jsonrpc.EndpointCodec{ Endpoint: endpoints.SumEndpoint, Decode: decodeSumRequest, Encode: encodeSumResponse, }, "concat": jsonrpc.EndpointCodec{ Endpoint: endpoints.ConcatEndpoi...
go
func makeEndpointCodecMap(endpoints addendpoint.Set) jsonrpc.EndpointCodecMap { return jsonrpc.EndpointCodecMap{ "sum": jsonrpc.EndpointCodec{ Endpoint: endpoints.SumEndpoint, Decode: decodeSumRequest, Encode: encodeSumResponse, }, "concat": jsonrpc.EndpointCodec{ Endpoint: endpoints.ConcatEndpoi...
[ "func", "makeEndpointCodecMap", "(", "endpoints", "addendpoint", ".", "Set", ")", "jsonrpc", ".", "EndpointCodecMap", "{", "return", "jsonrpc", ".", "EndpointCodecMap", "{", "\"", "\"", ":", "jsonrpc", ".", "EndpointCodec", "{", "Endpoint", ":", "endpoints", "."...
// makeEndpointCodecMap returns a codec map configured for the addsvc.
[ "makeEndpointCodecMap", "returns", "a", "codec", "map", "configured", "for", "the", "addsvc", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addtransport/jsonrpc.go#L98-L111
126,856
go-kit/kit
examples/profilesvc/transport.go
MakeHTTPHandler
func MakeHTTPHandler(s Service, logger log.Logger) http.Handler { r := mux.NewRouter() e := MakeServerEndpoints(s) options := []httptransport.ServerOption{ httptransport.ServerErrorHandler(transport.NewLogErrorHandler(logger)), httptransport.ServerErrorEncoder(encodeError), } // POST /profiles/ ...
go
func MakeHTTPHandler(s Service, logger log.Logger) http.Handler { r := mux.NewRouter() e := MakeServerEndpoints(s) options := []httptransport.ServerOption{ httptransport.ServerErrorHandler(transport.NewLogErrorHandler(logger)), httptransport.ServerErrorEncoder(encodeError), } // POST /profiles/ ...
[ "func", "MakeHTTPHandler", "(", "s", "Service", ",", "logger", "log", ".", "Logger", ")", "http", ".", "Handler", "{", "r", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "e", ":=", "MakeServerEndpoints", "(", "s", ")", "\n", "options", ":=", "[", "]...
// MakeHTTPHandler mounts all of the service endpoints into an http.Handler. // Useful in a profilesvc server.
[ "MakeHTTPHandler", "mounts", "all", "of", "the", "service", "endpoints", "into", "an", "http", ".", "Handler", ".", "Useful", "in", "a", "profilesvc", "server", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/profilesvc/transport.go#L29-L102
126,857
go-kit/kit
auth/jwt/middleware.go
NewParser
func NewParser(keyFunc jwt.Keyfunc, method jwt.SigningMethod, newClaims ClaimsFactory) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { // tokenString is stored in the context from the transport ...
go
func NewParser(keyFunc jwt.Keyfunc, method jwt.SigningMethod, newClaims ClaimsFactory) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { // tokenString is stored in the context from the transport ...
[ "func", "NewParser", "(", "keyFunc", "jwt", ".", "Keyfunc", ",", "method", "jwt", ".", "SigningMethod", ",", "newClaims", "ClaimsFactory", ")", "endpoint", ".", "Middleware", "{", "return", "func", "(", "next", "endpoint", ".", "Endpoint", ")", "endpoint", "...
// NewParser creates a new JWT token parsing middleware, specifying a // jwt.Keyfunc interface, the signing method and the claims type to be used. NewParser // adds the resulting claims to endpoint context or returns error on invalid token. // Particularly useful for servers.
[ "NewParser", "creates", "a", "new", "JWT", "token", "parsing", "middleware", "specifying", "a", "jwt", ".", "Keyfunc", "interface", "the", "signing", "method", "and", "the", "claims", "type", "to", "be", "used", ".", "NewParser", "adds", "the", "resulting", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/auth/jwt/middleware.go#L89-L143
126,858
go-kit/kit
metrics/statsd/statsd.go
New
func New(prefix string, logger log.Logger) *Statsd { return &Statsd{ prefix: prefix, rates: ratemap.New(), counters: lv.NewSpace(), gauges: lv.NewSpace(), timings: lv.NewSpace(), logger: logger, } }
go
func New(prefix string, logger log.Logger) *Statsd { return &Statsd{ prefix: prefix, rates: ratemap.New(), counters: lv.NewSpace(), gauges: lv.NewSpace(), timings: lv.NewSpace(), logger: logger, } }
[ "func", "New", "(", "prefix", "string", ",", "logger", "log", ".", "Logger", ")", "*", "Statsd", "{", "return", "&", "Statsd", "{", "prefix", ":", "prefix", ",", "rates", ":", "ratemap", ".", "New", "(", ")", ",", "counters", ":", "lv", ".", "NewSp...
// New returns a Statsd object that may be used to create metrics. Prefix is // applied to all created metrics. Callers must ensure that regular calls to // WriteTo are performed, either manually or with one of the helper methods.
[ "New", "returns", "a", "Statsd", "object", "that", "may", "be", "used", "to", "create", "metrics", ".", "Prefix", "is", "applied", "to", "all", "created", "metrics", ".", "Callers", "must", "ensure", "that", "regular", "calls", "to", "WriteTo", "are", "per...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/statsd/statsd.go#L53-L62
126,859
go-kit/kit
metrics/statsd/statsd.go
NewCounter
func (s *Statsd) NewCounter(name string, sampleRate float64) *Counter { s.rates.Set(s.prefix+name, sampleRate) return &Counter{ name: s.prefix + name, obs: s.counters.Observe, } }
go
func (s *Statsd) NewCounter(name string, sampleRate float64) *Counter { s.rates.Set(s.prefix+name, sampleRate) return &Counter{ name: s.prefix + name, obs: s.counters.Observe, } }
[ "func", "(", "s", "*", "Statsd", ")", "NewCounter", "(", "name", "string", ",", "sampleRate", "float64", ")", "*", "Counter", "{", "s", ".", "rates", ".", "Set", "(", "s", ".", "prefix", "+", "name", ",", "sampleRate", ")", "\n", "return", "&", "Co...
// NewCounter returns a counter, sending observations to this Statsd object.
[ "NewCounter", "returns", "a", "counter", "sending", "observations", "to", "this", "Statsd", "object", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/statsd/statsd.go#L65-L71
126,860
go-kit/kit
metrics/statsd/statsd.go
NewGauge
func (s *Statsd) NewGauge(name string) *Gauge { return &Gauge{ name: s.prefix + name, obs: s.gauges.Observe, add: s.gauges.Add, } }
go
func (s *Statsd) NewGauge(name string) *Gauge { return &Gauge{ name: s.prefix + name, obs: s.gauges.Observe, add: s.gauges.Add, } }
[ "func", "(", "s", "*", "Statsd", ")", "NewGauge", "(", "name", "string", ")", "*", "Gauge", "{", "return", "&", "Gauge", "{", "name", ":", "s", ".", "prefix", "+", "name", ",", "obs", ":", "s", ".", "gauges", ".", "Observe", ",", "add", ":", "s...
// NewGauge returns a gauge, sending observations to this Statsd object.
[ "NewGauge", "returns", "a", "gauge", "sending", "observations", "to", "this", "Statsd", "object", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/statsd/statsd.go#L74-L80
126,861
go-kit/kit
metrics/statsd/statsd.go
NewTiming
func (s *Statsd) NewTiming(name string, sampleRate float64) *Timing { s.rates.Set(s.prefix+name, sampleRate) return &Timing{ name: s.prefix + name, obs: s.timings.Observe, } }
go
func (s *Statsd) NewTiming(name string, sampleRate float64) *Timing { s.rates.Set(s.prefix+name, sampleRate) return &Timing{ name: s.prefix + name, obs: s.timings.Observe, } }
[ "func", "(", "s", "*", "Statsd", ")", "NewTiming", "(", "name", "string", ",", "sampleRate", "float64", ")", "*", "Timing", "{", "s", ".", "rates", ".", "Set", "(", "s", ".", "prefix", "+", "name", ",", "sampleRate", ")", "\n", "return", "&", "Timi...
// NewTiming returns a histogram whose observations are interpreted as // millisecond durations, and are forwarded to this Statsd object.
[ "NewTiming", "returns", "a", "histogram", "whose", "observations", "are", "interpreted", "as", "millisecond", "durations", "and", "are", "forwarded", "to", "this", "Statsd", "object", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/statsd/statsd.go#L84-L90
126,862
go-kit/kit
metrics/statsd/statsd.go
WriteTo
func (s *Statsd) WriteTo(w io.Writer) (count int64, err error) { var n int s.counters.Reset().Walk(func(name string, _ lv.LabelValues, values []float64) bool { n, err = fmt.Fprintf(w, "%s:%f|c%s\n", name, sum(values), sampling(s.rates.Get(name))) if err != nil { return false } count += int64(n) return t...
go
func (s *Statsd) WriteTo(w io.Writer) (count int64, err error) { var n int s.counters.Reset().Walk(func(name string, _ lv.LabelValues, values []float64) bool { n, err = fmt.Fprintf(w, "%s:%f|c%s\n", name, sum(values), sampling(s.rates.Get(name))) if err != nil { return false } count += int64(n) return t...
[ "func", "(", "s", "*", "Statsd", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "count", "int64", ",", "err", "error", ")", "{", "var", "n", "int", "\n\n", "s", ".", "counters", ".", "Reset", "(", ")", ".", "Walk", "(", "func", "(", ...
// WriteTo flushes the buffered content of the metrics to the writer, in // StatsD format. WriteTo abides best-effort semantics, so observations are // lost if there is a problem with the write. Clients should be sure to call // WriteTo regularly, ideally through the WriteLoop or SendLoop helper methods.
[ "WriteTo", "flushes", "the", "buffered", "content", "of", "the", "metrics", "to", "the", "writer", "in", "StatsD", "format", ".", "WriteTo", "abides", "best", "-", "effort", "semantics", "so", "observations", "are", "lost", "if", "there", "is", "a", "problem...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/statsd/statsd.go#L122-L165
126,863
go-kit/kit
transport/http/jsonrpc/request_response_types.go
UnmarshalJSON
func (id *RequestID) UnmarshalJSON(b []byte) error { id.intError = json.Unmarshal(b, &id.intValue) id.floatError = json.Unmarshal(b, &id.floatValue) id.stringError = json.Unmarshal(b, &id.stringValue) return nil }
go
func (id *RequestID) UnmarshalJSON(b []byte) error { id.intError = json.Unmarshal(b, &id.intValue) id.floatError = json.Unmarshal(b, &id.floatValue) id.stringError = json.Unmarshal(b, &id.stringValue) return nil }
[ "func", "(", "id", "*", "RequestID", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "id", ".", "intError", "=", "json", ".", "Unmarshal", "(", "b", ",", "&", "id", ".", "intValue", ")", "\n", "id", ".", "floatError", "=", "j...
// UnmarshalJSON satisfies json.Unmarshaler
[ "UnmarshalJSON", "satisfies", "json", ".", "Unmarshaler" ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/jsonrpc/request_response_types.go#L30-L36
126,864
go-kit/kit
util/conn/manager.go
NewManager
func NewManager(d Dialer, network, address string, after AfterFunc, logger log.Logger) *Manager { m := &Manager{ dialer: d, network: network, address: address, after: after, logger: logger, takec: make(chan net.Conn), putc: make(chan error), } go m.loop() return m }
go
func NewManager(d Dialer, network, address string, after AfterFunc, logger log.Logger) *Manager { m := &Manager{ dialer: d, network: network, address: address, after: after, logger: logger, takec: make(chan net.Conn), putc: make(chan error), } go m.loop() return m }
[ "func", "NewManager", "(", "d", "Dialer", ",", "network", ",", "address", "string", ",", "after", "AfterFunc", ",", "logger", "log", ".", "Logger", ")", "*", "Manager", "{", "m", ":=", "&", "Manager", "{", "dialer", ":", "d", ",", "network", ":", "ne...
// NewManager returns a connection manager using the passed Dialer, network, and // address. The AfterFunc is used to control exponential backoff and retries. // The logger is used to log errors; pass a log.NopLogger if you don't care to // receive them. For normal use, prefer NewDefaultManager.
[ "NewManager", "returns", "a", "connection", "manager", "using", "the", "passed", "Dialer", "network", "and", "address", ".", "The", "AfterFunc", "is", "used", "to", "control", "exponential", "backoff", "and", "retries", ".", "The", "logger", "is", "used", "to"...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/util/conn/manager.go#L41-L54
126,865
go-kit/kit
log/level/level.go
NewFilter
func NewFilter(next log.Logger, options ...Option) log.Logger { l := &logger{ next: next, } for _, option := range options { option(l) } return l }
go
func NewFilter(next log.Logger, options ...Option) log.Logger { l := &logger{ next: next, } for _, option := range options { option(l) } return l }
[ "func", "NewFilter", "(", "next", "log", ".", "Logger", ",", "options", "...", "Option", ")", "log", ".", "Logger", "{", "l", ":=", "&", "logger", "{", "next", ":", "next", ",", "}", "\n", "for", "_", ",", "option", ":=", "range", "options", "{", ...
// NewFilter wraps next and implements level filtering. See the commentary on // the Option functions for a detailed description of how to configure levels. // If no options are provided, all leveled log events created with Debug, // Info, Warn or Error helper methods are squelched and non-leveled log // events are pas...
[ "NewFilter", "wraps", "next", "and", "implements", "level", "filtering", ".", "See", "the", "commentary", "on", "the", "Option", "functions", "for", "a", "detailed", "description", "of", "how", "to", "configure", "levels", ".", "If", "no", "options", "are", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/level/level.go#L30-L38
126,866
go-kit/kit
sd/consul/instancer.go
NewInstancer
func NewInstancer(client Client, logger log.Logger, service string, tags []string, passingOnly bool) *Instancer { s := &Instancer{ cache: instance.NewCache(), client: client, logger: log.With(logger, "service", service, "tags", fmt.Sprint(tags)), service: service, tags: tags, pas...
go
func NewInstancer(client Client, logger log.Logger, service string, tags []string, passingOnly bool) *Instancer { s := &Instancer{ cache: instance.NewCache(), client: client, logger: log.With(logger, "service", service, "tags", fmt.Sprint(tags)), service: service, tags: tags, pas...
[ "func", "NewInstancer", "(", "client", "Client", ",", "logger", "log", ".", "Logger", ",", "service", "string", ",", "tags", "[", "]", "string", ",", "passingOnly", "bool", ")", "*", "Instancer", "{", "s", ":=", "&", "Instancer", "{", "cache", ":", "in...
// NewInstancer returns a Consul instancer that publishes instances for the // requested service. It only returns instances for which all of the passed tags // are present.
[ "NewInstancer", "returns", "a", "Consul", "instancer", "that", "publishes", "instances", "for", "the", "requested", "service", ".", "It", "only", "returns", "instances", "for", "which", "all", "of", "the", "passed", "tags", "are", "present", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/consul/instancer.go#L35-L56
126,867
go-kit/kit
log/value.go
TimestampFormat
func TimestampFormat(t func() time.Time, layout string) Valuer { return func() interface{} { return timeFormat{ time: t(), layout: layout, } } }
go
func TimestampFormat(t func() time.Time, layout string) Valuer { return func() interface{} { return timeFormat{ time: t(), layout: layout, } } }
[ "func", "TimestampFormat", "(", "t", "func", "(", ")", "time", ".", "Time", ",", "layout", "string", ")", "Valuer", "{", "return", "func", "(", ")", "interface", "{", "}", "{", "return", "timeFormat", "{", "time", ":", "t", "(", ")", ",", "layout", ...
// TimestampFormat returns a timestamp Valuer with a custom time format. It // invokes the t function to get the time to format; unless you are doing // something tricky, pass time.Now. The layout string is passed to // Time.Format. // // Most users will want to use DefaultTimestamp or DefaultTimestampUTC, which // are...
[ "TimestampFormat", "returns", "a", "timestamp", "Valuer", "with", "a", "custom", "time", "format", ".", "It", "invokes", "the", "t", "function", "to", "get", "the", "time", "to", "format", ";", "unless", "you", "are", "doing", "something", "tricky", "pass", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/value.go#L52-L59
126,868
go-kit/kit
log/value.go
MarshalText
func (tf timeFormat) MarshalText() (text []byte, err error) { // The following code adapted from the standard library time.Time.Format // method. Using the same undocumented magic constant to extend the size // of the buffer as seen there. b := make([]byte, 0, len(tf.layout)+10) b = tf.time.AppendFormat(b, tf.layo...
go
func (tf timeFormat) MarshalText() (text []byte, err error) { // The following code adapted from the standard library time.Time.Format // method. Using the same undocumented magic constant to extend the size // of the buffer as seen there. b := make([]byte, 0, len(tf.layout)+10) b = tf.time.AppendFormat(b, tf.layo...
[ "func", "(", "tf", "timeFormat", ")", "MarshalText", "(", ")", "(", "text", "[", "]", "byte", ",", "err", "error", ")", "{", "// The following code adapted from the standard library time.Time.Format", "// method. Using the same undocumented magic constant to extend the size", ...
// MarshalText implements encoding.TextMarshaller.
[ "MarshalText", "implements", "encoding", ".", "TextMarshaller", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/value.go#L73-L80
126,869
go-kit/kit
log/value.go
Caller
func Caller(depth int) Valuer { return func() interface{} { _, file, line, _ := runtime.Caller(depth) idx := strings.LastIndexByte(file, '/') // using idx+1 below handles both of following cases: // idx == -1 because no "/" was found, or // idx >= 0 and we want to start at the character after the found "/". ...
go
func Caller(depth int) Valuer { return func() interface{} { _, file, line, _ := runtime.Caller(depth) idx := strings.LastIndexByte(file, '/') // using idx+1 below handles both of following cases: // idx == -1 because no "/" was found, or // idx >= 0 and we want to start at the character after the found "/". ...
[ "func", "Caller", "(", "depth", "int", ")", "Valuer", "{", "return", "func", "(", ")", "interface", "{", "}", "{", "_", ",", "file", ",", "line", ",", "_", ":=", "runtime", ".", "Caller", "(", "depth", ")", "\n", "idx", ":=", "strings", ".", "Las...
// Caller returns a Valuer that returns a file and line from a specified depth // in the callstack. Users will probably want to use DefaultCaller.
[ "Caller", "returns", "a", "Valuer", "that", "returns", "a", "file", "and", "line", "from", "a", "specified", "depth", "in", "the", "callstack", ".", "Users", "will", "probably", "want", "to", "use", "DefaultCaller", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/log/value.go#L84-L93
126,870
go-kit/kit
auth/basic/middleware.go
AuthMiddleware
func AuthMiddleware(requiredUser, requiredPassword, realm string) endpoint.Middleware { requiredUserBytes := toHashSlice([]byte(requiredUser)) requiredPasswordBytes := toHashSlice([]byte(requiredPassword)) return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}...
go
func AuthMiddleware(requiredUser, requiredPassword, realm string) endpoint.Middleware { requiredUserBytes := toHashSlice([]byte(requiredUser)) requiredPasswordBytes := toHashSlice([]byte(requiredPassword)) return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}...
[ "func", "AuthMiddleware", "(", "requiredUser", ",", "requiredPassword", ",", "realm", "string", ")", "endpoint", ".", "Middleware", "{", "requiredUserBytes", ":=", "toHashSlice", "(", "[", "]", "byte", "(", "requiredUser", ")", ")", "\n", "requiredPasswordBytes", ...
// AuthMiddleware returns a Basic Authentication middleware for a particular user and password.
[ "AuthMiddleware", "returns", "a", "Basic", "Authentication", "middleware", "for", "a", "particular", "user", "and", "password", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/auth/basic/middleware.go#L67-L94
126,871
go-kit/kit
sd/lb/random.go
NewRandom
func NewRandom(s sd.Endpointer, seed int64) Balancer { return &random{ s: s, r: rand.New(rand.NewSource(seed)), } }
go
func NewRandom(s sd.Endpointer, seed int64) Balancer { return &random{ s: s, r: rand.New(rand.NewSource(seed)), } }
[ "func", "NewRandom", "(", "s", "sd", ".", "Endpointer", ",", "seed", "int64", ")", "Balancer", "{", "return", "&", "random", "{", "s", ":", "s", ",", "r", ":", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "seed", ")", ")", ",", "}", ...
// NewRandom returns a load balancer that selects services randomly.
[ "NewRandom", "returns", "a", "load", "balancer", "that", "selects", "services", "randomly", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/lb/random.go#L11-L16
126,872
go-kit/kit
metrics/internal/ratemap/ratemap.go
Get
func (m *RateMap) Get(name string) float64 { m.mtx.RLock() defer m.mtx.RUnlock() f, ok := m.m[name] if !ok { f = 1.0 } return f }
go
func (m *RateMap) Get(name string) float64 { m.mtx.RLock() defer m.mtx.RUnlock() f, ok := m.m[name] if !ok { f = 1.0 } return f }
[ "func", "(", "m", "*", "RateMap", ")", "Get", "(", "name", "string", ")", "float64", "{", "m", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "f", ",", "ok", ":=", "m", ".", "m", "[", "na...
// Get retrieves the rate for the given name, or 1.0 if none is set. // Get is safe for concurrent access by multiple goroutines.
[ "Get", "retrieves", "the", "rate", "for", "the", "given", "name", "or", "1", ".", "0", "if", "none", "is", "set", ".", "Get", "is", "safe", "for", "concurrent", "access", "by", "multiple", "goroutines", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/metrics/internal/ratemap/ratemap.go#L32-L40
126,873
go-kit/kit
examples/addsvc/pkg/addendpoint/set.go
New
func New(svc addservice.Service, logger log.Logger, duration metrics.Histogram, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer) Set { var sumEndpoint endpoint.Endpoint { sumEndpoint = MakeSumEndpoint(svc) sumEndpoint = ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 1))(sumEn...
go
func New(svc addservice.Service, logger log.Logger, duration metrics.Histogram, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer) Set { var sumEndpoint endpoint.Endpoint { sumEndpoint = MakeSumEndpoint(svc) sumEndpoint = ratelimit.NewErroringLimiter(rate.NewLimiter(rate.Every(time.Second), 1))(sumEn...
[ "func", "New", "(", "svc", "addservice", ".", "Service", ",", "logger", "log", ".", "Logger", ",", "duration", "metrics", ".", "Histogram", ",", "otTracer", "stdopentracing", ".", "Tracer", ",", "zipkinTracer", "*", "stdzipkin", ".", "Tracer", ")", "Set", ...
// New returns a Set that wraps the provided server, and wires in all of the // expected endpoint middlewares via the various parameters.
[ "New", "returns", "a", "Set", "that", "wraps", "the", "provided", "server", "and", "wires", "in", "all", "of", "the", "expected", "endpoint", "middlewares", "via", "the", "various", "parameters", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addendpoint/set.go#L34-L59
126,874
go-kit/kit
examples/addsvc/pkg/addendpoint/set.go
Sum
func (s Set) Sum(ctx context.Context, a, b int) (int, error) { resp, err := s.SumEndpoint(ctx, SumRequest{A: a, B: b}) if err != nil { return 0, err } response := resp.(SumResponse) return response.V, response.Err }
go
func (s Set) Sum(ctx context.Context, a, b int) (int, error) { resp, err := s.SumEndpoint(ctx, SumRequest{A: a, B: b}) if err != nil { return 0, err } response := resp.(SumResponse) return response.V, response.Err }
[ "func", "(", "s", "Set", ")", "Sum", "(", "ctx", "context", ".", "Context", ",", "a", ",", "b", "int", ")", "(", "int", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "SumEndpoint", "(", "ctx", ",", "SumRequest", "{", "A", ":", "...
// Sum implements the service interface, so Set may be used as a service. // This is primarily useful in the context of a client library.
[ "Sum", "implements", "the", "service", "interface", "so", "Set", "may", "be", "used", "as", "a", "service", ".", "This", "is", "primarily", "useful", "in", "the", "context", "of", "a", "client", "library", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addendpoint/set.go#L63-L70
126,875
go-kit/kit
examples/addsvc/pkg/addendpoint/set.go
Concat
func (s Set) Concat(ctx context.Context, a, b string) (string, error) { resp, err := s.ConcatEndpoint(ctx, ConcatRequest{A: a, B: b}) if err != nil { return "", err } response := resp.(ConcatResponse) return response.V, response.Err }
go
func (s Set) Concat(ctx context.Context, a, b string) (string, error) { resp, err := s.ConcatEndpoint(ctx, ConcatRequest{A: a, B: b}) if err != nil { return "", err } response := resp.(ConcatResponse) return response.V, response.Err }
[ "func", "(", "s", "Set", ")", "Concat", "(", "ctx", "context", ".", "Context", ",", "a", ",", "b", "string", ")", "(", "string", ",", "error", ")", "{", "resp", ",", "err", ":=", "s", ".", "ConcatEndpoint", "(", "ctx", ",", "ConcatRequest", "{", ...
// Concat implements the service interface, so Set may be used as a // service. This is primarily useful in the context of a client library.
[ "Concat", "implements", "the", "service", "interface", "so", "Set", "may", "be", "used", "as", "a", "service", ".", "This", "is", "primarily", "useful", "in", "the", "context", "of", "a", "client", "library", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addendpoint/set.go#L74-L81
126,876
go-kit/kit
examples/addsvc/pkg/addendpoint/set.go
MakeSumEndpoint
func MakeSumEndpoint(s addservice.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { req := request.(SumRequest) v, err := s.Sum(ctx, req.A, req.B) return SumResponse{V: v, Err: err}, nil } }
go
func MakeSumEndpoint(s addservice.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { req := request.(SumRequest) v, err := s.Sum(ctx, req.A, req.B) return SumResponse{V: v, Err: err}, nil } }
[ "func", "MakeSumEndpoint", "(", "s", "addservice", ".", "Service", ")", "endpoint", ".", "Endpoint", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "request", "interface", "{", "}", ")", "(", "response", "interface", "{", "}", ",", "e...
// MakeSumEndpoint constructs a Sum endpoint wrapping the service.
[ "MakeSumEndpoint", "constructs", "a", "Sum", "endpoint", "wrapping", "the", "service", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addendpoint/set.go#L84-L90
126,877
go-kit/kit
examples/addsvc/pkg/addendpoint/set.go
MakeConcatEndpoint
func MakeConcatEndpoint(s addservice.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { req := request.(ConcatRequest) v, err := s.Concat(ctx, req.A, req.B) return ConcatResponse{V: v, Err: err}, nil } }
go
func MakeConcatEndpoint(s addservice.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (response interface{}, err error) { req := request.(ConcatRequest) v, err := s.Concat(ctx, req.A, req.B) return ConcatResponse{V: v, Err: err}, nil } }
[ "func", "MakeConcatEndpoint", "(", "s", "addservice", ".", "Service", ")", "endpoint", ".", "Endpoint", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "request", "interface", "{", "}", ")", "(", "response", "interface", "{", "}", ",", ...
// MakeConcatEndpoint constructs a Concat endpoint wrapping the service.
[ "MakeConcatEndpoint", "constructs", "a", "Concat", "endpoint", "wrapping", "the", "service", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/addsvc/pkg/addendpoint/set.go#L93-L99
126,878
go-kit/kit
examples/shipping/voyage/voyage.go
New
func New(n Number, s Schedule) *Voyage { return &Voyage{Number: n, Schedule: s} }
go
func New(n Number, s Schedule) *Voyage { return &Voyage{Number: n, Schedule: s} }
[ "func", "New", "(", "n", "Number", ",", "s", "Schedule", ")", "*", "Voyage", "{", "return", "&", "Voyage", "{", "Number", ":", "n", ",", "Schedule", ":", "s", "}", "\n", "}" ]
// New creates a voyage with a voyage number and a provided schedule.
[ "New", "creates", "a", "voyage", "with", "a", "voyage", "number", "and", "a", "provided", "schedule", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/shipping/voyage/voyage.go#L21-L23
126,879
go-kit/kit
tracing/opencensus/grpc.go
GRPCClientTrace
func GRPCClientTrace(options ...TracerOption) kitgrpc.ClientOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } clientBefore := kitgrpc.ClientBefore( func(ctx context.Context, md *metadata.MD) context.Context { var name string if cfg.Name != "" { name = cfg.Name } els...
go
func GRPCClientTrace(options ...TracerOption) kitgrpc.ClientOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } clientBefore := kitgrpc.ClientBefore( func(ctx context.Context, md *metadata.MD) context.Context { var name string if cfg.Name != "" { name = cfg.Name } els...
[ "func", "GRPCClientTrace", "(", "options", "...", "TracerOption", ")", "kitgrpc", ".", "ClientOption", "{", "cfg", ":=", "TracerOptions", "{", "}", "\n\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "cfg", ")", "\n", "}...
// GRPCClientTrace enables OpenCensus tracing of a Go kit gRPC transport client.
[ "GRPCClientTrace", "enables", "OpenCensus", "tracing", "of", "a", "Go", "kit", "gRPC", "transport", "client", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opencensus/grpc.go#L18-L68
126,880
go-kit/kit
tracing/opencensus/grpc.go
GRPCServerTrace
func GRPCServerTrace(options ...TracerOption) kitgrpc.ServerOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } serverBefore := kitgrpc.ServerBefore( func(ctx context.Context, md metadata.MD) context.Context { var name string if cfg.Name != "" { name = cfg.Name } else...
go
func GRPCServerTrace(options ...TracerOption) kitgrpc.ServerOption { cfg := TracerOptions{} for _, option := range options { option(&cfg) } serverBefore := kitgrpc.ServerBefore( func(ctx context.Context, md metadata.MD) context.Context { var name string if cfg.Name != "" { name = cfg.Name } else...
[ "func", "GRPCServerTrace", "(", "options", "...", "TracerOption", ")", "kitgrpc", ".", "ServerOption", "{", "cfg", ":=", "TracerOptions", "{", "}", "\n\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "cfg", ")", "\n", "}...
// GRPCServerTrace enables OpenCensus tracing of a Go kit gRPC transport server.
[ "GRPCServerTrace", "enables", "OpenCensus", "tracing", "of", "a", "Go", "kit", "gRPC", "transport", "server", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/opencensus/grpc.go#L71-L149
126,881
go-kit/kit
tracing/zipkin/endpoint.go
TraceEndpoint
func TraceEndpoint(tracer *zipkin.Tracer, name string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { var sc model.SpanContext if parentSpan := zipkin.SpanFromContext(ctx); parentSpan != nil { sc = p...
go
func TraceEndpoint(tracer *zipkin.Tracer, name string) endpoint.Middleware { return func(next endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { var sc model.SpanContext if parentSpan := zipkin.SpanFromContext(ctx); parentSpan != nil { sc = p...
[ "func", "TraceEndpoint", "(", "tracer", "*", "zipkin", ".", "Tracer", ",", "name", "string", ")", "endpoint", ".", "Middleware", "{", "return", "func", "(", "next", "endpoint", ".", "Endpoint", ")", "endpoint", ".", "Endpoint", "{", "return", "func", "(", ...
// TraceEndpoint returns an Endpoint middleware, tracing a Go kit endpoint. // This endpoint tracer should be used in combination with a Go kit Transport // tracing middleware or custom before and after transport functions as // propagation of SpanContext is not provided in this middleware.
[ "TraceEndpoint", "returns", "an", "Endpoint", "middleware", "tracing", "a", "Go", "kit", "endpoint", ".", "This", "endpoint", "tracer", "should", "be", "used", "in", "combination", "with", "a", "Go", "kit", "Transport", "tracing", "middleware", "or", "custom", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/tracing/zipkin/endpoint.go#L16-L30
126,882
go-kit/kit
sd/zk/client.go
ACL
func ACL(acl []zk.ACL) Option { return func(c *clientConfig) error { c.acl = acl return nil } }
go
func ACL(acl []zk.ACL) Option { return func(c *clientConfig) error { c.acl = acl return nil } }
[ "func", "ACL", "(", "acl", "[", "]", "zk", ".", "ACL", ")", "Option", "{", "return", "func", "(", "c", "*", "clientConfig", ")", "error", "{", "c", ".", "acl", "=", "acl", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ACL returns an Option specifying a non-default ACL for creating parent nodes.
[ "ACL", "returns", "an", "Option", "specifying", "a", "non", "-", "default", "ACL", "for", "creating", "parent", "nodes", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L69-L74
126,883
go-kit/kit
sd/zk/client.go
ConnectTimeout
func ConnectTimeout(t time.Duration) Option { return func(c *clientConfig) error { if t.Seconds() < 1 { return errors.New("invalid connect timeout (minimum value is 1 second)") } c.connectTimeout = t return nil } }
go
func ConnectTimeout(t time.Duration) Option { return func(c *clientConfig) error { if t.Seconds() < 1 { return errors.New("invalid connect timeout (minimum value is 1 second)") } c.connectTimeout = t return nil } }
[ "func", "ConnectTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "clientConfig", ")", "error", "{", "if", "t", ".", "Seconds", "(", ")", "<", "1", "{", "return", "errors", ".", "New", "(", "\"", "\""...
// ConnectTimeout returns an Option specifying a non-default connection timeout // when we try to establish a connection to a ZooKeeper server.
[ "ConnectTimeout", "returns", "an", "Option", "specifying", "a", "non", "-", "default", "connection", "timeout", "when", "we", "try", "to", "establish", "a", "connection", "to", "a", "ZooKeeper", "server", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L90-L98
126,884
go-kit/kit
sd/zk/client.go
SessionTimeout
func SessionTimeout(t time.Duration) Option { return func(c *clientConfig) error { if t.Seconds() < 1 { return errors.New("invalid session timeout (minimum value is 1 second)") } c.sessionTimeout = t return nil } }
go
func SessionTimeout(t time.Duration) Option { return func(c *clientConfig) error { if t.Seconds() < 1 { return errors.New("invalid session timeout (minimum value is 1 second)") } c.sessionTimeout = t return nil } }
[ "func", "SessionTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "*", "clientConfig", ")", "error", "{", "if", "t", ".", "Seconds", "(", ")", "<", "1", "{", "return", "errors", ".", "New", "(", "\"", "\""...
// SessionTimeout returns an Option specifying a non-default session timeout.
[ "SessionTimeout", "returns", "an", "Option", "specifying", "a", "non", "-", "default", "session", "timeout", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L101-L109
126,885
go-kit/kit
sd/zk/client.go
Payload
func Payload(payload [][]byte) Option { return func(c *clientConfig) error { c.rootNodePayload = payload return nil } }
go
func Payload(payload [][]byte) Option { return func(c *clientConfig) error { c.rootNodePayload = payload return nil } }
[ "func", "Payload", "(", "payload", "[", "]", "[", "]", "byte", ")", "Option", "{", "return", "func", "(", "c", "*", "clientConfig", ")", "error", "{", "c", ".", "rootNodePayload", "=", "payload", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Payload returns an Option specifying non-default data values for each znode // created by CreateParentNodes.
[ "Payload", "returns", "an", "Option", "specifying", "non", "-", "default", "data", "values", "for", "each", "znode", "created", "by", "CreateParentNodes", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L113-L118
126,886
go-kit/kit
sd/zk/client.go
NewClient
func NewClient(servers []string, logger log.Logger, options ...Option) (Client, error) { defaultEventHandler := func(event zk.Event) { logger.Log("eventtype", event.Type.String(), "server", event.Server, "state", event.State.String(), "err", event.Err) } config := clientConfig{ acl: DefaultACL, conn...
go
func NewClient(servers []string, logger log.Logger, options ...Option) (Client, error) { defaultEventHandler := func(event zk.Event) { logger.Log("eventtype", event.Type.String(), "server", event.Server, "state", event.State.String(), "err", event.Err) } config := clientConfig{ acl: DefaultACL, conn...
[ "func", "NewClient", "(", "servers", "[", "]", "string", ",", "logger", "log", ".", "Logger", ",", "options", "...", "Option", ")", "(", "Client", ",", "error", ")", "{", "defaultEventHandler", ":=", "func", "(", "event", "zk", ".", "Event", ")", "{", ...
// NewClient returns a ZooKeeper client with a connection to the server cluster. // It will return an error if the server cluster cannot be resolved.
[ "NewClient", "returns", "a", "ZooKeeper", "client", "with", "a", "connection", "to", "the", "server", "cluster", ".", "It", "will", "return", "an", "error", "if", "the", "server", "cluster", "cannot", "be", "resolved", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L131-L182
126,887
go-kit/kit
sd/zk/client.go
CreateParentNodes
func (c *client) CreateParentNodes(path string) error { if !c.active { return ErrClientClosed } if path[0] != '/' { return zk.ErrInvalidPath } payload := []byte("") pathString := "" pathNodes := strings.Split(path, "/") for i := 1; i < len(pathNodes); i++ { if i <= len(c.rootNodePayload) { payload = c....
go
func (c *client) CreateParentNodes(path string) error { if !c.active { return ErrClientClosed } if path[0] != '/' { return zk.ErrInvalidPath } payload := []byte("") pathString := "" pathNodes := strings.Split(path, "/") for i := 1; i < len(pathNodes); i++ { if i <= len(c.rootNodePayload) { payload = c....
[ "func", "(", "c", "*", "client", ")", "CreateParentNodes", "(", "path", "string", ")", "error", "{", "if", "!", "c", ".", "active", "{", "return", "ErrClientClosed", "\n", "}", "\n", "if", "path", "[", "0", "]", "!=", "'/'", "{", "return", "zk", "....
// CreateParentNodes implements the ZooKeeper Client interface.
[ "CreateParentNodes", "implements", "the", "ZooKeeper", "Client", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L185-L211
126,888
go-kit/kit
sd/zk/client.go
GetEntries
func (c *client) GetEntries(path string) ([]string, <-chan zk.Event, error) { // retrieve list of child nodes for given path and add watch to path znodes, _, eventc, err := c.ChildrenW(path) if err != nil { return nil, eventc, err } var resp []string for _, znode := range znodes { // retrieve payload for ch...
go
func (c *client) GetEntries(path string) ([]string, <-chan zk.Event, error) { // retrieve list of child nodes for given path and add watch to path znodes, _, eventc, err := c.ChildrenW(path) if err != nil { return nil, eventc, err } var resp []string for _, znode := range znodes { // retrieve payload for ch...
[ "func", "(", "c", "*", "client", ")", "GetEntries", "(", "path", "string", ")", "(", "[", "]", "string", ",", "<-", "chan", "zk", ".", "Event", ",", "error", ")", "{", "// retrieve list of child nodes for given path and add watch to path", "znodes", ",", "_", ...
// GetEntries implements the ZooKeeper Client interface.
[ "GetEntries", "implements", "the", "ZooKeeper", "Client", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L214-L230
126,889
go-kit/kit
sd/zk/client.go
Register
func (c *client) Register(s *Service) error { if s.Path[len(s.Path)-1] != '/' { s.Path += "/" } path := s.Path + s.Name if err := c.CreateParentNodes(path); err != nil { return err } if path[len(path)-1] != '/' { path += "/" } node, err := c.CreateProtectedEphemeralSequential(path, s.Data, c.acl) if err ...
go
func (c *client) Register(s *Service) error { if s.Path[len(s.Path)-1] != '/' { s.Path += "/" } path := s.Path + s.Name if err := c.CreateParentNodes(path); err != nil { return err } if path[len(path)-1] != '/' { path += "/" } node, err := c.CreateProtectedEphemeralSequential(path, s.Data, c.acl) if err ...
[ "func", "(", "c", "*", "client", ")", "Register", "(", "s", "*", "Service", ")", "error", "{", "if", "s", ".", "Path", "[", "len", "(", "s", ".", "Path", ")", "-", "1", "]", "!=", "'/'", "{", "s", ".", "Path", "+=", "\"", "\"", "\n", "}", ...
// Register implements the ZooKeeper Client interface.
[ "Register", "implements", "the", "ZooKeeper", "Client", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L233-L250
126,890
go-kit/kit
sd/zk/client.go
Deregister
func (c *client) Deregister(s *Service) error { if s.node == "" { return ErrNotRegistered } path := s.Path + s.Name found, stat, err := c.Exists(path) if err != nil { return err } if !found { return ErrNodeNotFound } if err := c.Delete(path, stat.Version); err != nil { return err } return nil }
go
func (c *client) Deregister(s *Service) error { if s.node == "" { return ErrNotRegistered } path := s.Path + s.Name found, stat, err := c.Exists(path) if err != nil { return err } if !found { return ErrNodeNotFound } if err := c.Delete(path, stat.Version); err != nil { return err } return nil }
[ "func", "(", "c", "*", "client", ")", "Deregister", "(", "s", "*", "Service", ")", "error", "{", "if", "s", ".", "node", "==", "\"", "\"", "{", "return", "ErrNotRegistered", "\n", "}", "\n", "path", ":=", "s", ".", "Path", "+", "s", ".", "Name", ...
// Deregister implements the ZooKeeper Client interface.
[ "Deregister", "implements", "the", "ZooKeeper", "Client", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L253-L269
126,891
go-kit/kit
sd/zk/client.go
Stop
func (c *client) Stop() { c.active = false close(c.quit) c.Close() }
go
func (c *client) Stop() { c.active = false close(c.quit) c.Close() }
[ "func", "(", "c", "*", "client", ")", "Stop", "(", ")", "{", "c", ".", "active", "=", "false", "\n", "close", "(", "c", ".", "quit", ")", "\n", "c", ".", "Close", "(", ")", "\n", "}" ]
// Stop implements the ZooKeeper Client interface.
[ "Stop", "implements", "the", "ZooKeeper", "Client", "interface", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/zk/client.go#L272-L276
126,892
go-kit/kit
transport/nats/publisher.go
EncodeJSONRequest
func EncodeJSONRequest(_ context.Context, msg *nats.Msg, request interface{}) error { b, err := json.Marshal(request) if err != nil { return err } msg.Data = b return nil }
go
func EncodeJSONRequest(_ context.Context, msg *nats.Msg, request interface{}) error { b, err := json.Marshal(request) if err != nil { return err } msg.Data = b return nil }
[ "func", "EncodeJSONRequest", "(", "_", "context", ".", "Context", ",", "msg", "*", "nats", ".", "Msg", ",", "request", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "request", ")", "\n", "if", "err", ...
// EncodeJSONRequest is an EncodeRequestFunc that serializes the request as a // JSON object to the Data of the Msg. Many JSON-over-NATS services can use it as // a sensible default.
[ "EncodeJSONRequest", "is", "an", "EncodeRequestFunc", "that", "serializes", "the", "request", "as", "a", "JSON", "object", "to", "the", "Data", "of", "the", "Msg", ".", "Many", "JSON", "-", "over", "-", "NATS", "services", "can", "use", "it", "as", "a", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/nats/publisher.go#L101-L110
126,893
go-kit/kit
sd/lb/retry.go
Retry
func Retry(max int, timeout time.Duration, b Balancer) endpoint.Endpoint { return RetryWithCallback(timeout, b, maxRetries(max)) }
go
func Retry(max int, timeout time.Duration, b Balancer) endpoint.Endpoint { return RetryWithCallback(timeout, b, maxRetries(max)) }
[ "func", "Retry", "(", "max", "int", ",", "timeout", "time", ".", "Duration", ",", "b", "Balancer", ")", "endpoint", ".", "Endpoint", "{", "return", "RetryWithCallback", "(", "timeout", ",", "b", ",", "maxRetries", "(", "max", ")", ")", "\n", "}" ]
// Retry wraps a service load balancer and returns an endpoint oriented load // balancer for the specified service method. Requests to the endpoint will be // automatically load balanced via the load balancer. Requests that return // errors will be retried until they succeed, up to max times, or until the // timeout is...
[ "Retry", "wraps", "a", "service", "load", "balancer", "and", "returns", "an", "endpoint", "oriented", "load", "balancer", "for", "the", "specified", "service", "method", ".", "Requests", "to", "the", "endpoint", "will", "be", "automatically", "load", "balanced",...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/lb/retry.go#L44-L46
126,894
go-kit/kit
sd/lb/retry.go
RetryWithCallback
func RetryWithCallback(timeout time.Duration, b Balancer, cb Callback) endpoint.Endpoint { if cb == nil { cb = alwaysRetry } if b == nil { panic("nil Balancer") } return func(ctx context.Context, request interface{}) (response interface{}, err error) { var ( newctx, cancel = context.WithTimeout(ctx, time...
go
func RetryWithCallback(timeout time.Duration, b Balancer, cb Callback) endpoint.Endpoint { if cb == nil { cb = alwaysRetry } if b == nil { panic("nil Balancer") } return func(ctx context.Context, request interface{}) (response interface{}, err error) { var ( newctx, cancel = context.WithTimeout(ctx, time...
[ "func", "RetryWithCallback", "(", "timeout", "time", ".", "Duration", ",", "b", "Balancer", ",", "cb", "Callback", ")", "endpoint", ".", "Endpoint", "{", "if", "cb", "==", "nil", "{", "cb", "=", "alwaysRetry", "\n", "}", "\n", "if", "b", "==", "nil", ...
// RetryWithCallback wraps a service load balancer and returns an endpoint // oriented load balancer for the specified service method. Requests to the // endpoint will be automatically load balanced via the load balancer. Requests // that return errors will be retried until they succeed, up to max times, until // the c...
[ "RetryWithCallback", "wraps", "a", "service", "load", "balancer", "and", "returns", "an", "endpoint", "oriented", "load", "balancer", "for", "the", "specified", "service", "method", ".", "Requests", "to", "the", "endpoint", "will", "be", "automatically", "load", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/lb/retry.go#L64-L117
126,895
go-kit/kit
examples/stringsvc4/main.go
main
func main() { svc := stringService{} natsURL := flag.String("nats-url", nats.DefaultURL, "URL for connection to NATS") flag.Parse() nc, err := nats.Connect(*natsURL) if err != nil { log.Fatal(err) } defer nc.Close() uppercaseHTTPHandler := httptransport.NewServer( makeUppercaseHTTPEndpoint(nc), decodeU...
go
func main() { svc := stringService{} natsURL := flag.String("nats-url", nats.DefaultURL, "URL for connection to NATS") flag.Parse() nc, err := nats.Connect(*natsURL) if err != nil { log.Fatal(err) } defer nc.Close() uppercaseHTTPHandler := httptransport.NewServer( makeUppercaseHTTPEndpoint(nc), decodeU...
[ "func", "main", "(", ")", "{", "svc", ":=", "stringService", "{", "}", "\n\n", "natsURL", ":=", "flag", ".", "String", "(", "\"", "\"", ",", "nats", ".", "DefaultURL", ",", "\"", "\"", ")", "\n", "flag", ".", "Parse", "(", ")", "\n\n", "nc", ",",...
// Transports expose the service to the network. In this fourth example we utilize JSON over NATS and HTTP.
[ "Transports", "expose", "the", "service", "to", "the", "network", ".", "In", "this", "fourth", "example", "we", "utilize", "JSON", "over", "NATS", "and", "HTTP", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/examples/stringsvc4/main.go#L99-L151
126,896
go-kit/kit
sd/etcd/registrar.go
NewTTLOption
func NewTTLOption(heartbeat, ttl time.Duration) *TTLOption { if heartbeat <= minHeartBeatTime { heartbeat = minHeartBeatTime } if ttl <= heartbeat { ttl = 3 * heartbeat } return &TTLOption{ heartbeat: heartbeat, ttl: ttl, } }
go
func NewTTLOption(heartbeat, ttl time.Duration) *TTLOption { if heartbeat <= minHeartBeatTime { heartbeat = minHeartBeatTime } if ttl <= heartbeat { ttl = 3 * heartbeat } return &TTLOption{ heartbeat: heartbeat, ttl: ttl, } }
[ "func", "NewTTLOption", "(", "heartbeat", ",", "ttl", "time", ".", "Duration", ")", "*", "TTLOption", "{", "if", "heartbeat", "<=", "minHeartBeatTime", "{", "heartbeat", "=", "minHeartBeatTime", "\n", "}", "\n", "if", "ttl", "<=", "heartbeat", "{", "ttl", ...
// NewTTLOption returns a TTLOption that contains proper TTL settings. Heartbeat // is used to refresh the lease of the key periodically; its value should be at // least 500ms. TTL defines the lease of the key; its value should be // significantly greater than heartbeat. // // Good default values might be 3s heartbeat,...
[ "NewTTLOption", "returns", "a", "TTLOption", "that", "contains", "proper", "TTL", "settings", ".", "Heartbeat", "is", "used", "to", "refresh", "the", "lease", "of", "the", "key", "periodically", ";", "its", "value", "should", "be", "at", "least", "500ms", "....
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/etcd/registrar.go#L47-L58
126,897
go-kit/kit
sd/etcd/registrar.go
Register
func (r *Registrar) Register() { if err := r.client.Register(r.service); err != nil { r.logger.Log("err", err) } else { r.logger.Log("action", "register") } if r.service.TTL != nil { go r.loop() } }
go
func (r *Registrar) Register() { if err := r.client.Register(r.service); err != nil { r.logger.Log("err", err) } else { r.logger.Log("action", "register") } if r.service.TTL != nil { go r.loop() } }
[ "func", "(", "r", "*", "Registrar", ")", "Register", "(", ")", "{", "if", "err", ":=", "r", ".", "client", ".", "Register", "(", "r", ".", "service", ")", ";", "err", "!=", "nil", "{", "r", ".", "logger", ".", "Log", "(", "\"", "\"", ",", "er...
// Register implements the sd.Registrar interface. Call it when you want your // service to be registered in etcd, typically at startup.
[ "Register", "implements", "the", "sd", ".", "Registrar", "interface", ".", "Call", "it", "when", "you", "want", "your", "service", "to", "be", "registered", "in", "etcd", "typically", "at", "startup", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/etcd/registrar.go#L72-L81
126,898
go-kit/kit
sd/etcd/registrar.go
Deregister
func (r *Registrar) Deregister() { if err := r.client.Deregister(r.service); err != nil { r.logger.Log("err", err) } else { r.logger.Log("action", "deregister") } r.quitmtx.Lock() defer r.quitmtx.Unlock() if r.quit != nil { close(r.quit) r.quit = nil } }
go
func (r *Registrar) Deregister() { if err := r.client.Deregister(r.service); err != nil { r.logger.Log("err", err) } else { r.logger.Log("action", "deregister") } r.quitmtx.Lock() defer r.quitmtx.Unlock() if r.quit != nil { close(r.quit) r.quit = nil } }
[ "func", "(", "r", "*", "Registrar", ")", "Deregister", "(", ")", "{", "if", "err", ":=", "r", ".", "client", ".", "Deregister", "(", "r", ".", "service", ")", ";", "err", "!=", "nil", "{", "r", ".", "logger", ".", "Log", "(", "\"", "\"", ",", ...
// Deregister implements the sd.Registrar interface. Call it when you want your // service to be deregistered from etcd, typically just prior to shutdown.
[ "Deregister", "implements", "the", "sd", ".", "Registrar", "interface", ".", "Call", "it", "when", "you", "want", "your", "service", "to", "be", "deregistered", "from", "etcd", "typically", "just", "prior", "to", "shutdown", "." ]
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/sd/etcd/registrar.go#L107-L120
126,899
go-kit/kit
transport/http/client.go
EncodeJSONRequest
func EncodeJSONRequest(c context.Context, r *http.Request, request interface{}) error { r.Header.Set("Content-Type", "application/json; charset=utf-8") if headerer, ok := request.(Headerer); ok { for k := range headerer.Headers() { r.Header.Set(k, headerer.Headers().Get(k)) } } var b bytes.Buffer r.Body = i...
go
func EncodeJSONRequest(c context.Context, r *http.Request, request interface{}) error { r.Header.Set("Content-Type", "application/json; charset=utf-8") if headerer, ok := request.(Headerer); ok { for k := range headerer.Headers() { r.Header.Set(k, headerer.Headers().Get(k)) } } var b bytes.Buffer r.Body = i...
[ "func", "EncodeJSONRequest", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ",", "request", "interface", "{", "}", ")", "error", "{", "r", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", ...
// EncodeJSONRequest is an EncodeRequestFunc that serializes the request as a // JSON object to the Request body. Many JSON-over-HTTP services can use it as // a sensible default. If the request implements Headerer, the provided headers // will be applied to the request.
[ "EncodeJSONRequest", "is", "an", "EncodeRequestFunc", "that", "serializes", "the", "request", "as", "a", "JSON", "object", "to", "the", "Request", "body", ".", "Many", "JSON", "-", "over", "-", "HTTP", "services", "can", "use", "it", "as", "a", "sensible", ...
da68e7640663097af890b9bdd76da9cb816ebb82
https://github.com/go-kit/kit/blob/da68e7640663097af890b9bdd76da9cb816ebb82/transport/http/client.go#L184-L194