id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
27,300
robertkrimen/otto
otto.go
MakeSyntaxError
func (self Otto) MakeSyntaxError(message string) Value { return self.runtime.toValue(self.runtime.newSyntaxError(self.runtime.toValue(message))) }
go
func (self Otto) MakeSyntaxError(message string) Value { return self.runtime.toValue(self.runtime.newSyntaxError(self.runtime.toValue(message))) }
[ "func", "(", "self", "Otto", ")", "MakeSyntaxError", "(", "message", "string", ")", "Value", "{", "return", "self", ".", "runtime", ".", "toValue", "(", "self", ".", "runtime", ".", "newSyntaxError", "(", "self", ".", "runtime", ".", "toValue", "(", "mes...
// MakeSyntaxError creates a new SyntaxError object with the given message, // returning it as a Value.
[ "MakeSyntaxError", "creates", "a", "new", "SyntaxError", "object", "with", "the", "given", "message", "returning", "it", "as", "a", "Value", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L408-L410
27,301
robertkrimen/otto
otto.go
MakeTypeError
func (self Otto) MakeTypeError(message string) Value { return self.runtime.toValue(self.runtime.newTypeError(self.runtime.toValue(message))) }
go
func (self Otto) MakeTypeError(message string) Value { return self.runtime.toValue(self.runtime.newTypeError(self.runtime.toValue(message))) }
[ "func", "(", "self", "Otto", ")", "MakeTypeError", "(", "message", "string", ")", "Value", "{", "return", "self", ".", "runtime", ".", "toValue", "(", "self", ".", "runtime", ".", "newTypeError", "(", "self", ".", "runtime", ".", "toValue", "(", "message...
// MakeTypeError creates a new TypeError object with the given message, // returning it as a Value.
[ "MakeTypeError", "creates", "a", "new", "TypeError", "object", "with", "the", "given", "message", "returning", "it", "as", "a", "Value", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L414-L416
27,302
robertkrimen/otto
otto.go
ContextLimit
func (self Otto) ContextLimit(limit int) Context { return self.ContextSkip(limit, true) }
go
func (self Otto) ContextLimit(limit int) Context { return self.ContextSkip(limit, true) }
[ "func", "(", "self", "Otto", ")", "ContextLimit", "(", "limit", "int", ")", "Context", "{", "return", "self", ".", "ContextSkip", "(", "limit", ",", "true", ")", "\n", "}" ]
// ContextLimit returns the current execution context of the vm, with a // specific limit on the number of stack frames to traverse, skipping any // innermost native function stack frames.
[ "ContextLimit", "returns", "the", "current", "execution", "context", "of", "the", "vm", "with", "a", "specific", "limit", "on", "the", "number", "of", "stack", "frames", "to", "traverse", "skipping", "any", "innermost", "native", "function", "stack", "frames", ...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L439-L441
27,303
robertkrimen/otto
otto.go
ContextSkip
func (self Otto) ContextSkip(limit int, skipNative bool) (ctx Context) { // Ensure we are operating in a scope if self.runtime.scope == nil { self.runtime.enterGlobalScope() defer self.runtime.leaveScope() } scope := self.runtime.scope frame := scope.frame for skipNative && frame.native && scope.outer != ni...
go
func (self Otto) ContextSkip(limit int, skipNative bool) (ctx Context) { // Ensure we are operating in a scope if self.runtime.scope == nil { self.runtime.enterGlobalScope() defer self.runtime.leaveScope() } scope := self.runtime.scope frame := scope.frame for skipNative && frame.native && scope.outer != ni...
[ "func", "(", "self", "Otto", ")", "ContextSkip", "(", "limit", "int", ",", "skipNative", "bool", ")", "(", "ctx", "Context", ")", "{", "// Ensure we are operating in a scope", "if", "self", ".", "runtime", ".", "scope", "==", "nil", "{", "self", ".", "runt...
// ContextSkip returns the current execution context of the vm, with a // specific limit on the number of stack frames to traverse, optionally // skipping any innermost native function stack frames.
[ "ContextSkip", "returns", "the", "current", "execution", "context", "of", "the", "vm", "with", "a", "specific", "limit", "on", "the", "number", "of", "stack", "frames", "to", "traverse", "optionally", "skipping", "any", "innermost", "native", "function", "stack"...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L446-L515
27,304
robertkrimen/otto
otto.go
Get
func (self Object) Get(name string) (Value, error) { value := Value{} err := catchPanic(func() { value = self.object.get(name) }) if !value.safe() { value = Value{} } return value, err }
go
func (self Object) Get(name string) (Value, error) { value := Value{} err := catchPanic(func() { value = self.object.get(name) }) if !value.safe() { value = Value{} } return value, err }
[ "func", "(", "self", "Object", ")", "Get", "(", "name", "string", ")", "(", "Value", ",", "error", ")", "{", "value", ":=", "Value", "{", "}", "\n", "err", ":=", "catchPanic", "(", "func", "(", ")", "{", "value", "=", "self", ".", "object", ".", ...
// Get the value of the property with the given name.
[ "Get", "the", "value", "of", "the", "property", "with", "the", "given", "name", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L696-L705
27,305
robertkrimen/otto
otto.go
Keys
func (self Object) Keys() []string { var keys []string self.object.enumerate(false, func(name string) bool { keys = append(keys, name) return true }) return keys }
go
func (self Object) Keys() []string { var keys []string self.object.enumerate(false, func(name string) bool { keys = append(keys, name) return true }) return keys }
[ "func", "(", "self", "Object", ")", "Keys", "(", ")", "[", "]", "string", "{", "var", "keys", "[", "]", "string", "\n", "self", ".", "object", ".", "enumerate", "(", "false", ",", "func", "(", "name", "string", ")", "bool", "{", "keys", "=", "app...
// Keys gets the keys for the given object. // // Equivalent to calling Object.keys on the object.
[ "Keys", "gets", "the", "keys", "for", "the", "given", "object", ".", "Equivalent", "to", "calling", "Object", ".", "keys", "on", "the", "object", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto.go#L727-L734
27,306
grpc-ecosystem/go-grpc-middleware
recovery/options.go
WithRecoveryHandler
func WithRecoveryHandler(f RecoveryHandlerFunc) Option { return func(o *options) { o.recoveryHandlerFunc = RecoveryHandlerFuncContext(func(ctx context.Context, p interface{}) error { return f(p) }) } }
go
func WithRecoveryHandler(f RecoveryHandlerFunc) Option { return func(o *options) { o.recoveryHandlerFunc = RecoveryHandlerFuncContext(func(ctx context.Context, p interface{}) error { return f(p) }) } }
[ "func", "WithRecoveryHandler", "(", "f", "RecoveryHandlerFunc", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "recoveryHandlerFunc", "=", "RecoveryHandlerFuncContext", "(", "func", "(", "ctx", "context", ".", "Context", ",...
// WithRecoveryHandler customizes the function for recovering from a panic.
[ "WithRecoveryHandler", "customizes", "the", "function", "for", "recovering", "from", "a", "panic", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/recovery/options.go#L30-L36
27,307
grpc-ecosystem/go-grpc-middleware
retry/options.go
WithMax
func WithMax(maxRetries uint) CallOption { return CallOption{applyFunc: func(o *options) { o.max = maxRetries }} }
go
func WithMax(maxRetries uint) CallOption { return CallOption{applyFunc: func(o *options) { o.max = maxRetries }} }
[ "func", "WithMax", "(", "maxRetries", "uint", ")", "CallOption", "{", "return", "CallOption", "{", "applyFunc", ":", "func", "(", "o", "*", "options", ")", "{", "o", ".", "max", "=", "maxRetries", "\n", "}", "}", "\n", "}" ]
// WithMax sets the maximum number of retries on this call, or this interceptor.
[ "WithMax", "sets", "the", "maximum", "number", "of", "retries", "on", "this", "call", "or", "this", "interceptor", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/retry/options.go#L56-L60
27,308
grpc-ecosystem/go-grpc-middleware
retry/options.go
WithBackoff
func WithBackoff(bf BackoffFunc) CallOption { return CallOption{applyFunc: func(o *options) { o.backoffFunc = BackoffFuncContext(func(ctx context.Context, attempt uint) time.Duration { return bf(attempt) }) }} }
go
func WithBackoff(bf BackoffFunc) CallOption { return CallOption{applyFunc: func(o *options) { o.backoffFunc = BackoffFuncContext(func(ctx context.Context, attempt uint) time.Duration { return bf(attempt) }) }} }
[ "func", "WithBackoff", "(", "bf", "BackoffFunc", ")", "CallOption", "{", "return", "CallOption", "{", "applyFunc", ":", "func", "(", "o", "*", "options", ")", "{", "o", ".", "backoffFunc", "=", "BackoffFuncContext", "(", "func", "(", "ctx", "context", ".",...
// WithBackoff sets the `BackoffFunc` used to control time between retries.
[ "WithBackoff", "sets", "the", "BackoffFunc", "used", "to", "control", "time", "between", "retries", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/retry/options.go#L63-L69
27,309
grpc-ecosystem/go-grpc-middleware
retry/options.go
WithBackoffContext
func WithBackoffContext(bf BackoffFuncContext) CallOption { return CallOption{applyFunc: func(o *options) { o.backoffFunc = bf }} }
go
func WithBackoffContext(bf BackoffFuncContext) CallOption { return CallOption{applyFunc: func(o *options) { o.backoffFunc = bf }} }
[ "func", "WithBackoffContext", "(", "bf", "BackoffFuncContext", ")", "CallOption", "{", "return", "CallOption", "{", "applyFunc", ":", "func", "(", "o", "*", "options", ")", "{", "o", ".", "backoffFunc", "=", "bf", "\n", "}", "}", "\n", "}" ]
// WithBackoffContext sets the `BackoffFuncContext` used to control time between retries.
[ "WithBackoffContext", "sets", "the", "BackoffFuncContext", "used", "to", "control", "time", "between", "retries", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/retry/options.go#L72-L76
27,310
grpc-ecosystem/go-grpc-middleware
logging/logrus/server_interceptors.go
UnaryServerInterceptor
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor { o := evaluateServerOpt(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { startTime := time.Now() newCtx := newLoggerForCall(ctx, entry,...
go
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor { o := evaluateServerOpt(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { startTime := time.Now() newCtx := newLoggerForCall(ctx, entry,...
[ "func", "UnaryServerInterceptor", "(", "entry", "*", "logrus", ".", "Entry", ",", "opts", "...", "Option", ")", "grpc", ".", "UnaryServerInterceptor", "{", "o", ":=", "evaluateServerOpt", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".", ...
// UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptors", "that", "adds", "logrus", ".", "Entry", "to", "the", "context", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/server_interceptors.go#L26-L55
27,311
grpc-ecosystem/go-grpc-middleware
logging/logrus/server_interceptors.go
StreamServerInterceptor
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor { o := evaluateServerOpt(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { startTime := time.Now() newCtx := newLoggerForCall(stream.Context(),...
go
func StreamServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamServerInterceptor { o := evaluateServerOpt(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { startTime := time.Now() newCtx := newLoggerForCall(stream.Context(),...
[ "func", "StreamServerInterceptor", "(", "entry", "*", "logrus", ".", "Entry", ",", "opts", "...", "Option", ")", "grpc", ".", "StreamServerInterceptor", "{", "o", ":=", "evaluateServerOpt", "(", "opts", ")", "\n", "return", "func", "(", "srv", "interface", "...
// StreamServerInterceptor returns a new streaming server interceptor that adds logrus.Entry to the context.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "server", "interceptor", "that", "adds", "logrus", ".", "Entry", "to", "the", "context", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/server_interceptors.go#L58-L89
27,312
grpc-ecosystem/go-grpc-middleware
logging/zap/client_interceptors.go
StreamClientInterceptor
func StreamClientInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamClientInterceptor { o := evaluateClientOpt(opts) return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { fields := newClientLo...
go
func StreamClientInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamClientInterceptor { o := evaluateClientOpt(opts) return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { fields := newClientLo...
[ "func", "StreamClientInterceptor", "(", "logger", "*", "zap", ".", "Logger", ",", "opts", "...", "Option", ")", "grpc", ".", "StreamClientInterceptor", "{", "o", ":=", "evaluateClientOpt", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".",...
// StreamClientInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
[ "StreamClientInterceptor", "returns", "a", "new", "streaming", "client", "interceptor", "that", "optionally", "logs", "the", "execution", "of", "external", "gRPC", "calls", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/client_interceptors.go#L34-L43
27,313
grpc-ecosystem/go-grpc-middleware
tags/options.go
WithFieldExtractorForInitialReq
func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option { return func(o *options) { o.requestFieldsFunc = f o.requestFieldsFromInitial = true } }
go
func WithFieldExtractorForInitialReq(f RequestFieldExtractorFunc) Option { return func(o *options) { o.requestFieldsFunc = f o.requestFieldsFromInitial = true } }
[ "func", "WithFieldExtractorForInitialReq", "(", "f", "RequestFieldExtractorFunc", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "requestFieldsFunc", "=", "f", "\n", "o", ".", "requestFieldsFromInitial", "=", "true", "\n", ...
// WithFieldExtractorForInitialReq customizes the function for extracting log fields from protobuf messages, // for all unary and streaming methods. For client-streams and bidirectional-streams, the tags will be // extracted from the first message from the client.
[ "WithFieldExtractorForInitialReq", "customizes", "the", "function", "for", "extracting", "log", "fields", "from", "protobuf", "messages", "for", "all", "unary", "and", "streaming", "methods", ".", "For", "client", "-", "streams", "and", "bidirectional", "-", "stream...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tags/options.go#L39-L44
27,314
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
ExtractIncoming
func ExtractIncoming(ctx context.Context) NiceMD { md, ok := metadata.FromIncomingContext(ctx) if !ok { return NiceMD(metadata.Pairs()) } return NiceMD(md) }
go
func ExtractIncoming(ctx context.Context) NiceMD { md, ok := metadata.FromIncomingContext(ctx) if !ok { return NiceMD(metadata.Pairs()) } return NiceMD(md) }
[ "func", "ExtractIncoming", "(", "ctx", "context", ".", "Context", ")", "NiceMD", "{", "md", ",", "ok", ":=", "metadata", ".", "FromIncomingContext", "(", "ctx", ")", "\n", "if", "!", "ok", "{", "return", "NiceMD", "(", "metadata", ".", "Pairs", "(", ")...
// ExtractIncoming extracts an inbound metadata from the server-side context. // // This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns // a new empty NiceMD.
[ "ExtractIncoming", "extracts", "an", "inbound", "metadata", "from", "the", "server", "-", "side", "context", ".", "This", "function", "always", "returns", "a", "NiceMD", "wrapper", "of", "the", "metadata", ".", "MD", "in", "case", "the", "context", "doesn", ...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L20-L26
27,315
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
ExtractOutgoing
func ExtractOutgoing(ctx context.Context) NiceMD { md, ok := metadata.FromOutgoingContext(ctx) if !ok { return NiceMD(metadata.Pairs()) } return NiceMD(md) }
go
func ExtractOutgoing(ctx context.Context) NiceMD { md, ok := metadata.FromOutgoingContext(ctx) if !ok { return NiceMD(metadata.Pairs()) } return NiceMD(md) }
[ "func", "ExtractOutgoing", "(", "ctx", "context", ".", "Context", ")", "NiceMD", "{", "md", ",", "ok", ":=", "metadata", ".", "FromOutgoingContext", "(", "ctx", ")", "\n", "if", "!", "ok", "{", "return", "NiceMD", "(", "metadata", ".", "Pairs", "(", ")...
// ExtractOutgoing extracts an outbound metadata from the client-side context. // // This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns // a new empty NiceMD.
[ "ExtractOutgoing", "extracts", "an", "outbound", "metadata", "from", "the", "client", "-", "side", "context", ".", "This", "function", "always", "returns", "a", "NiceMD", "wrapper", "of", "the", "metadata", ".", "MD", "in", "case", "the", "context", "doesn", ...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L32-L38
27,316
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
ToOutgoing
func (m NiceMD) ToOutgoing(ctx context.Context) context.Context { return metadata.NewOutgoingContext(ctx, metadata.MD(m)) }
go
func (m NiceMD) ToOutgoing(ctx context.Context) context.Context { return metadata.NewOutgoingContext(ctx, metadata.MD(m)) }
[ "func", "(", "m", "NiceMD", ")", "ToOutgoing", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "return", "metadata", ".", "NewOutgoingContext", "(", "ctx", ",", "metadata", ".", "MD", "(", "m", ")", ")", "\n", "}" ]
// ToOutgoing sets the given NiceMD as a client-side context for dispatching.
[ "ToOutgoing", "sets", "the", "given", "NiceMD", "as", "a", "client", "-", "side", "context", "for", "dispatching", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L68-L70
27,317
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
ToIncoming
func (m NiceMD) ToIncoming(ctx context.Context) context.Context { return metadata.NewIncomingContext(ctx, metadata.MD(m)) }
go
func (m NiceMD) ToIncoming(ctx context.Context) context.Context { return metadata.NewIncomingContext(ctx, metadata.MD(m)) }
[ "func", "(", "m", "NiceMD", ")", "ToIncoming", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "return", "metadata", ".", "NewIncomingContext", "(", "ctx", ",", "metadata", ".", "MD", "(", "m", ")", ")", "\n", "}" ]
// ToIncoming sets the given NiceMD as a server-side context for dispatching. // // This is mostly useful in ServerInterceptors..
[ "ToIncoming", "sets", "the", "given", "NiceMD", "as", "a", "server", "-", "side", "context", "for", "dispatching", ".", "This", "is", "mostly", "useful", "in", "ServerInterceptors", ".." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L75-L77
27,318
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
Get
func (m NiceMD) Get(key string) string { k, _ := encodeKeyValue(key, "") vv, ok := m[k] if !ok { return "" } return vv[0] }
go
func (m NiceMD) Get(key string) string { k, _ := encodeKeyValue(key, "") vv, ok := m[k] if !ok { return "" } return vv[0] }
[ "func", "(", "m", "NiceMD", ")", "Get", "(", "key", "string", ")", "string", "{", "k", ",", "_", ":=", "encodeKeyValue", "(", "key", ",", "\"", "\"", ")", "\n", "vv", ",", "ok", ":=", "m", "[", "k", "]", "\n", "if", "!", "ok", "{", "return", ...
// Get retrieves a single value from the metadata. // // It works analogously to http.Header.Get, returning the first value if there are many set. If the value is not set, // an empty string is returned. // // The function is binary-key safe.
[ "Get", "retrieves", "a", "single", "value", "from", "the", "metadata", ".", "It", "works", "analogously", "to", "http", ".", "Header", ".", "Get", "returning", "the", "first", "value", "if", "there", "are", "many", "set", ".", "If", "the", "value", "is",...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L85-L92
27,319
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
Del
func (m NiceMD) Del(key string) NiceMD { k, _ := encodeKeyValue(key, "") delete(m, k) return m }
go
func (m NiceMD) Del(key string) NiceMD { k, _ := encodeKeyValue(key, "") delete(m, k) return m }
[ "func", "(", "m", "NiceMD", ")", "Del", "(", "key", "string", ")", "NiceMD", "{", "k", ",", "_", ":=", "encodeKeyValue", "(", "key", ",", "\"", "\"", ")", "\n", "delete", "(", "m", ",", "k", ")", "\n", "return", "m", "\n", "}" ]
// Del retrieves a single value from the metadata. // // It works analogously to http.Header.Del, deleting all values if they exist. // // The function is binary-key safe.
[ "Del", "retrieves", "a", "single", "value", "from", "the", "metadata", ".", "It", "works", "analogously", "to", "http", ".", "Header", ".", "Del", "deleting", "all", "values", "if", "they", "exist", ".", "The", "function", "is", "binary", "-", "key", "sa...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L100-L104
27,320
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
Set
func (m NiceMD) Set(key string, value string) NiceMD { k, v := encodeKeyValue(key, value) m[k] = []string{v} return m }
go
func (m NiceMD) Set(key string, value string) NiceMD { k, v := encodeKeyValue(key, value) m[k] = []string{v} return m }
[ "func", "(", "m", "NiceMD", ")", "Set", "(", "key", "string", ",", "value", "string", ")", "NiceMD", "{", "k", ",", "v", ":=", "encodeKeyValue", "(", "key", ",", "value", ")", "\n", "m", "[", "k", "]", "=", "[", "]", "string", "{", "v", "}", ...
// Set sets the given value in a metadata. // // It works analogously to http.Header.Set, overwriting all previous metadata values. // // The function is binary-key safe.
[ "Set", "sets", "the", "given", "value", "in", "a", "metadata", ".", "It", "works", "analogously", "to", "http", ".", "Header", ".", "Set", "overwriting", "all", "previous", "metadata", "values", ".", "The", "function", "is", "binary", "-", "key", "safe", ...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L111-L115
27,321
grpc-ecosystem/go-grpc-middleware
util/metautils/nicemd.go
Add
func (m NiceMD) Add(key string, value string) NiceMD { k, v := encodeKeyValue(key, value) m[k] = append(m[k], v) return m }
go
func (m NiceMD) Add(key string, value string) NiceMD { k, v := encodeKeyValue(key, value) m[k] = append(m[k], v) return m }
[ "func", "(", "m", "NiceMD", ")", "Add", "(", "key", "string", ",", "value", "string", ")", "NiceMD", "{", "k", ",", "v", ":=", "encodeKeyValue", "(", "key", ",", "value", ")", "\n", "m", "[", "k", "]", "=", "append", "(", "m", "[", "k", "]", ...
// Add retrieves a single value from the metadata. // // It works analogously to http.Header.Add, as it appends to any existing values associated with key. // // The function is binary-key safe.
[ "Add", "retrieves", "a", "single", "value", "from", "the", "metadata", ".", "It", "works", "analogously", "to", "http", ".", "Header", ".", "Add", "as", "it", "appends", "to", "any", "existing", "values", "associated", "with", "key", ".", "The", "function"...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/util/metautils/nicemd.go#L122-L126
27,322
grpc-ecosystem/go-grpc-middleware
logging/logrus/ctxlogrus/context.go
AddFields
func AddFields(ctx context.Context, fields logrus.Fields) { l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger) if !ok || l == nil { return } for k, v := range fields { l.fields[k] = v } }
go
func AddFields(ctx context.Context, fields logrus.Fields) { l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger) if !ok || l == nil { return } for k, v := range fields { l.fields[k] = v } }
[ "func", "AddFields", "(", "ctx", "context", ".", "Context", ",", "fields", "logrus", ".", "Fields", ")", "{", "l", ",", "ok", ":=", "ctx", ".", "Value", "(", "ctxLoggerKey", ")", ".", "(", "*", "ctxLogger", ")", "\n", "if", "!", "ok", "||", "l", ...
// AddFields adds logrus fields to the logger.
[ "AddFields", "adds", "logrus", "fields", "to", "the", "logger", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/ctxlogrus/context.go#L21-L29
27,323
grpc-ecosystem/go-grpc-middleware
logging/logrus/ctxlogrus/context.go
Extract
func Extract(ctx context.Context) *logrus.Entry { l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger) if !ok || l == nil { return logrus.NewEntry(nullLogger) } fields := logrus.Fields{} // Add grpc_ctxtags tags metadata until now. tags := grpc_ctxtags.Extract(ctx) for k, v := range tags.Values() { fields[k] = v ...
go
func Extract(ctx context.Context) *logrus.Entry { l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger) if !ok || l == nil { return logrus.NewEntry(nullLogger) } fields := logrus.Fields{} // Add grpc_ctxtags tags metadata until now. tags := grpc_ctxtags.Extract(ctx) for k, v := range tags.Values() { fields[k] = v ...
[ "func", "Extract", "(", "ctx", "context", ".", "Context", ")", "*", "logrus", ".", "Entry", "{", "l", ",", "ok", ":=", "ctx", ".", "Value", "(", "ctxLoggerKey", ")", ".", "(", "*", "ctxLogger", ")", "\n", "if", "!", "ok", "||", "l", "==", "nil", ...
// Extract takes the call-scoped logrus.Entry from ctx_logrus middleware. // // If the ctx_logrus middleware wasn't used, a no-op `logrus.Entry` is returned. This makes it safe to // use regardless.
[ "Extract", "takes", "the", "call", "-", "scoped", "logrus", ".", "Entry", "from", "ctx_logrus", "middleware", ".", "If", "the", "ctx_logrus", "middleware", "wasn", "t", "used", "a", "no", "-", "op", "logrus", ".", "Entry", "is", "returned", ".", "This", ...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/ctxlogrus/context.go#L35-L55
27,324
grpc-ecosystem/go-grpc-middleware
logging/logrus/ctxlogrus/context.go
ToContext
func ToContext(ctx context.Context, entry *logrus.Entry) context.Context { l := &ctxLogger{ logger: entry, fields: logrus.Fields{}, } return context.WithValue(ctx, ctxLoggerKey, l) }
go
func ToContext(ctx context.Context, entry *logrus.Entry) context.Context { l := &ctxLogger{ logger: entry, fields: logrus.Fields{}, } return context.WithValue(ctx, ctxLoggerKey, l) }
[ "func", "ToContext", "(", "ctx", "context", ".", "Context", ",", "entry", "*", "logrus", ".", "Entry", ")", "context", ".", "Context", "{", "l", ":=", "&", "ctxLogger", "{", "logger", ":", "entry", ",", "fields", ":", "logrus", ".", "Fields", "{", "}...
// ToContext adds the logrus.Entry to the context for extraction later. // Returning the new context that has been created.
[ "ToContext", "adds", "the", "logrus", ".", "Entry", "to", "the", "context", "for", "extraction", "later", ".", "Returning", "the", "new", "context", "that", "has", "been", "created", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/ctxlogrus/context.go#L59-L65
27,325
grpc-ecosystem/go-grpc-middleware
logging/logrus/client_interceptors.go
StreamClientInterceptor
func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamClientInterceptor { o := evaluateClientOpt(opts) return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { fields := newClientL...
go
func StreamClientInterceptor(entry *logrus.Entry, opts ...Option) grpc.StreamClientInterceptor { o := evaluateClientOpt(opts) return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { fields := newClientL...
[ "func", "StreamClientInterceptor", "(", "entry", "*", "logrus", ".", "Entry", ",", "opts", "...", "Option", ")", "grpc", ".", "StreamClientInterceptor", "{", "o", ":=", "evaluateClientOpt", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", "."...
// StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "client", "interceptor", "that", "optionally", "logs", "the", "execution", "of", "external", "gRPC", "calls", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/client_interceptors.go#L28-L37
27,326
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/options.go
WithTracer
func WithTracer(tracer opentracing.Tracer) Option { return func(o *options) { o.tracer = tracer } }
go
func WithTracer(tracer opentracing.Tracer) Option { return func(o *options) { o.tracer = tracer } }
[ "func", "WithTracer", "(", "tracer", "opentracing", ".", "Tracer", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "tracer", "=", "tracer", "\n", "}", "\n", "}" ]
// WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.
[ "WithTracer", "sets", "a", "custom", "tracer", "to", "be", "used", "for", "this", "middleware", "otherwise", "the", "opentracing", ".", "GlobalTracer", "is", "used", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/options.go#L51-L55
27,327
grpc-ecosystem/go-grpc-middleware
recovery/interceptors.go
UnaryServerInterceptor
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (_ interface{}, err error) { defer func() { if r := recover(); r != nil { err = recoverFrom(ctx, r, o.r...
go
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (_ interface{}, err error) { defer func() { if r := recover(); r != nil { err = recoverFrom(ctx, r, o.r...
[ "func", "UnaryServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "UnaryServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}",...
// UnaryServerInterceptor returns a new unary server interceptor for panic recovery.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptor", "for", "panic", "recovery", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/recovery/interceptors.go#L20-L31
27,328
grpc-ecosystem/go-grpc-middleware
recovery/interceptors.go
StreamServerInterceptor
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { defer func() { if r := recover(); r != nil { err = recoverFrom(stream.Context(),...
go
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) { defer func() { if r := recover(); r != nil { err = recoverFrom(stream.Context(),...
[ "func", "StreamServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "StreamServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "srv", "interface", "{", "}", ",", "stream", "grpc", ".", "ServerS...
// StreamServerInterceptor returns a new streaming server interceptor for panic recovery.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "server", "interceptor", "for", "panic", "recovery", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/recovery/interceptors.go#L34-L45
27,329
grpc-ecosystem/go-grpc-middleware
logging/zap/options.go
WithDecider
func WithDecider(f grpc_logging.Decider) Option { return func(o *options) { o.shouldLog = f } }
go
func WithDecider(f grpc_logging.Decider) Option { return func(o *options) { o.shouldLog = f } }
[ "func", "WithDecider", "(", "f", "grpc_logging", ".", "Decider", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "shouldLog", "=", "f", "\n", "}", "\n", "}" ]
// WithDecider customizes the function for deciding if the gRPC interceptor logs should log.
[ "WithDecider", "customizes", "the", "function", "for", "deciding", "if", "the", "gRPC", "interceptor", "logs", "should", "log", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/options.go#L57-L61
27,330
grpc-ecosystem/go-grpc-middleware
logging/zap/options.go
WithCodes
func WithCodes(f grpc_logging.ErrorToCode) Option { return func(o *options) { o.codeFunc = f } }
go
func WithCodes(f grpc_logging.ErrorToCode) Option { return func(o *options) { o.codeFunc = f } }
[ "func", "WithCodes", "(", "f", "grpc_logging", ".", "ErrorToCode", ")", "Option", "{", "return", "func", "(", "o", "*", "options", ")", "{", "o", ".", "codeFunc", "=", "f", "\n", "}", "\n", "}" ]
// WithCodes customizes the function for mapping errors to error codes.
[ "WithCodes", "customizes", "the", "function", "for", "mapping", "errors", "to", "error", "codes", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/options.go#L71-L75
27,331
grpc-ecosystem/go-grpc-middleware
logging/zap/options.go
DefaultCodeToLevel
func DefaultCodeToLevel(code codes.Code) zapcore.Level { switch code { case codes.OK: return zap.InfoLevel case codes.Canceled: return zap.InfoLevel case codes.Unknown: return zap.ErrorLevel case codes.InvalidArgument: return zap.InfoLevel case codes.DeadlineExceeded: return zap.WarnLevel case codes.No...
go
func DefaultCodeToLevel(code codes.Code) zapcore.Level { switch code { case codes.OK: return zap.InfoLevel case codes.Canceled: return zap.InfoLevel case codes.Unknown: return zap.ErrorLevel case codes.InvalidArgument: return zap.InfoLevel case codes.DeadlineExceeded: return zap.WarnLevel case codes.No...
[ "func", "DefaultCodeToLevel", "(", "code", "codes", ".", "Code", ")", "zapcore", ".", "Level", "{", "switch", "code", "{", "case", "codes", ".", "OK", ":", "return", "zap", ".", "InfoLevel", "\n", "case", "codes", ".", "Canceled", ":", "return", "zap", ...
// DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.
[ "DefaultCodeToLevel", "is", "the", "default", "implementation", "of", "gRPC", "return", "codes", "and", "interceptor", "log", "level", "for", "server", "side", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/options.go#L85-L124
27,332
grpc-ecosystem/go-grpc-middleware
logging/zap/options.go
DurationToTimeMillisField
func DurationToTimeMillisField(duration time.Duration) zapcore.Field { return zap.Float32("grpc.time_ms", durationToMilliseconds(duration)) }
go
func DurationToTimeMillisField(duration time.Duration) zapcore.Field { return zap.Float32("grpc.time_ms", durationToMilliseconds(duration)) }
[ "func", "DurationToTimeMillisField", "(", "duration", "time", ".", "Duration", ")", "zapcore", ".", "Field", "{", "return", "zap", ".", "Float32", "(", "\"", "\"", ",", "durationToMilliseconds", "(", "duration", ")", ")", "\n", "}" ]
// DurationToTimeMillisField converts the duration to milliseconds and uses the key `grpc.time_ms`.
[ "DurationToTimeMillisField", "converts", "the", "duration", "to", "milliseconds", "and", "uses", "the", "key", "grpc", ".", "time_ms", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/options.go#L172-L174
27,333
grpc-ecosystem/go-grpc-middleware
logging/zap/server_interceptors.go
UnaryServerInterceptor
func UnaryServerInterceptor(logger *zap.Logger, opts ...Option) grpc.UnaryServerInterceptor { o := evaluateServerOpt(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { startTime := time.Now() newCtx := newLoggerForCall(ctx, logger...
go
func UnaryServerInterceptor(logger *zap.Logger, opts ...Option) grpc.UnaryServerInterceptor { o := evaluateServerOpt(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { startTime := time.Now() newCtx := newLoggerForCall(ctx, logger...
[ "func", "UnaryServerInterceptor", "(", "logger", "*", "zap", ".", "Logger", ",", "opts", "...", "Option", ")", "grpc", ".", "UnaryServerInterceptor", "{", "o", ":=", "evaluateServerOpt", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".", ...
// UnaryServerInterceptor returns a new unary server interceptors that adds zap.Logger to the context.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptors", "that", "adds", "zap", ".", "Logger", "to", "the", "context", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/server_interceptors.go#L25-L48
27,334
grpc-ecosystem/go-grpc-middleware
logging/zap/server_interceptors.go
StreamServerInterceptor
func StreamServerInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamServerInterceptor { o := evaluateServerOpt(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { startTime := time.Now() newCtx := newLoggerForCall(stream.Context(), ...
go
func StreamServerInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamServerInterceptor { o := evaluateServerOpt(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { startTime := time.Now() newCtx := newLoggerForCall(stream.Context(), ...
[ "func", "StreamServerInterceptor", "(", "logger", "*", "zap", ".", "Logger", ",", "opts", "...", "Option", ")", "grpc", ".", "StreamServerInterceptor", "{", "o", ":=", "evaluateServerOpt", "(", "opts", ")", "\n", "return", "func", "(", "srv", "interface", "{...
// StreamServerInterceptor returns a new streaming server interceptor that adds zap.Logger to the context.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "server", "interceptor", "that", "adds", "zap", ".", "Logger", "to", "the", "context", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/server_interceptors.go#L51-L75
27,335
grpc-ecosystem/go-grpc-middleware
chain.go
WithUnaryServerChain
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption { return grpc.UnaryInterceptor(ChainUnaryServer(interceptors...)) }
go
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption { return grpc.UnaryInterceptor(ChainUnaryServer(interceptors...)) }
[ "func", "WithUnaryServerChain", "(", "interceptors", "...", "grpc", ".", "UnaryServerInterceptor", ")", "grpc", ".", "ServerOption", "{", "return", "grpc", ".", "UnaryInterceptor", "(", "ChainUnaryServer", "(", "interceptors", "...", ")", ")", "\n", "}" ]
// Chain creates a single interceptor out of a chain of many interceptors. // // WithUnaryServerChain is a grpc.Server config option that accepts multiple unary interceptors. // Basically syntactic sugar.
[ "Chain", "creates", "a", "single", "interceptor", "out", "of", "a", "chain", "of", "many", "interceptors", ".", "WithUnaryServerChain", "is", "a", "grpc", ".", "Server", "config", "option", "that", "accepts", "multiple", "unary", "interceptors", ".", "Basically"...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/chain.go#L175-L177
27,336
grpc-ecosystem/go-grpc-middleware
chain.go
WithStreamServerChain
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption { return grpc.StreamInterceptor(ChainStreamServer(interceptors...)) }
go
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption { return grpc.StreamInterceptor(ChainStreamServer(interceptors...)) }
[ "func", "WithStreamServerChain", "(", "interceptors", "...", "grpc", ".", "StreamServerInterceptor", ")", "grpc", ".", "ServerOption", "{", "return", "grpc", ".", "StreamInterceptor", "(", "ChainStreamServer", "(", "interceptors", "...", ")", ")", "\n", "}" ]
// WithStreamServerChain is a grpc.Server config option that accepts multiple stream interceptors. // Basically syntactic sugar.
[ "WithStreamServerChain", "is", "a", "grpc", ".", "Server", "config", "option", "that", "accepts", "multiple", "stream", "interceptors", ".", "Basically", "syntactic", "sugar", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/chain.go#L181-L183
27,337
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/client_interceptors.go
UnaryClientInterceptor
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor { o := evaluateOptions(opts) return func(parentCtx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { if o.filterOutFunc != nil && !o.filterOutFunc(parentCtx,...
go
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor { o := evaluateOptions(opts) return func(parentCtx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { if o.filterOutFunc != nil && !o.filterOutFunc(parentCtx,...
[ "func", "UnaryClientInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "UnaryClientInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "parentCtx", "context", ".", "Context", ",", "method", "string", ",", ...
// UnaryClientInterceptor returns a new unary client interceptor for OpenTracing.
[ "UnaryClientInterceptor", "returns", "a", "new", "unary", "client", "interceptor", "for", "OpenTracing", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/client_interceptors.go#L21-L32
27,338
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/client_interceptors.go
StreamClientInterceptor
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor { o := evaluateOptions(opts) return func(parentCtx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { if o.filterOutFunc != nil && !o.filte...
go
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor { o := evaluateOptions(opts) return func(parentCtx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { if o.filterOutFunc != nil && !o.filte...
[ "func", "StreamClientInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "StreamClientInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "parentCtx", "context", ".", "Context", ",", "desc", "*", "grpc", ...
// StreamClientInterceptor returns a new streaming client interceptor for OpenTracing.
[ "StreamClientInterceptor", "returns", "a", "new", "streaming", "client", "interceptor", "for", "OpenTracing", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/client_interceptors.go#L35-L49
27,339
grpc-ecosystem/go-grpc-middleware
logging/logrus/options.go
DefaultCodeToLevel
func DefaultCodeToLevel(code codes.Code) logrus.Level { switch code { case codes.OK: return logrus.InfoLevel case codes.Canceled: return logrus.InfoLevel case codes.Unknown: return logrus.ErrorLevel case codes.InvalidArgument: return logrus.InfoLevel case codes.DeadlineExceeded: return logrus.WarnLevel ...
go
func DefaultCodeToLevel(code codes.Code) logrus.Level { switch code { case codes.OK: return logrus.InfoLevel case codes.Canceled: return logrus.InfoLevel case codes.Unknown: return logrus.ErrorLevel case codes.InvalidArgument: return logrus.InfoLevel case codes.DeadlineExceeded: return logrus.WarnLevel ...
[ "func", "DefaultCodeToLevel", "(", "code", "codes", ".", "Code", ")", "logrus", ".", "Level", "{", "switch", "code", "{", "case", "codes", ".", "OK", ":", "return", "logrus", ".", "InfoLevel", "\n", "case", "codes", ".", "Canceled", ":", "return", "logru...
// DefaultCodeToLevel is the default implementation of gRPC return codes to log levels for server side.
[ "DefaultCodeToLevel", "is", "the", "default", "implementation", "of", "gRPC", "return", "codes", "to", "log", "levels", "for", "server", "side", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/logrus/options.go#L87-L126
27,340
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/metadata.go
Set
func (m metadataTextMap) Set(key, val string) { // gRPC allows for complex binary values to be written. encodedKey, encodedVal := encodeKeyValue(key, val) // The metadata object is a multimap, and previous values may exist, but for opentracing headers, we do not append // we just override. m[encodedKey] = []string...
go
func (m metadataTextMap) Set(key, val string) { // gRPC allows for complex binary values to be written. encodedKey, encodedVal := encodeKeyValue(key, val) // The metadata object is a multimap, and previous values may exist, but for opentracing headers, we do not append // we just override. m[encodedKey] = []string...
[ "func", "(", "m", "metadataTextMap", ")", "Set", "(", "key", ",", "val", "string", ")", "{", "// gRPC allows for complex binary values to be written.", "encodedKey", ",", "encodedVal", ":=", "encodeKeyValue", "(", "key", ",", "val", ")", "\n", "// The metadata objec...
// Set is a opentracing.TextMapReader interface that extracts values.
[ "Set", "is", "a", "opentracing", ".", "TextMapReader", "interface", "that", "extracts", "values", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/metadata.go#L23-L29
27,341
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/metadata.go
ForeachKey
func (m metadataTextMap) ForeachKey(callback func(key, val string) error) error { for k, vv := range m { for _, v := range vv { if decodedKey, decodedVal, err := metadata.DecodeKeyValue(k, v); err == nil { if err = callback(decodedKey, decodedVal); err != nil { return err } } else { return fmt...
go
func (m metadataTextMap) ForeachKey(callback func(key, val string) error) error { for k, vv := range m { for _, v := range vv { if decodedKey, decodedVal, err := metadata.DecodeKeyValue(k, v); err == nil { if err = callback(decodedKey, decodedVal); err != nil { return err } } else { return fmt...
[ "func", "(", "m", "metadataTextMap", ")", "ForeachKey", "(", "callback", "func", "(", "key", ",", "val", "string", ")", "error", ")", "error", "{", "for", "k", ",", "vv", ":=", "range", "m", "{", "for", "_", ",", "v", ":=", "range", "vv", "{", "i...
// ForeachKey is a opentracing.TextMapReader interface that extracts values.
[ "ForeachKey", "is", "a", "opentracing", ".", "TextMapReader", "interface", "that", "extracts", "values", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/metadata.go#L32-L45
27,342
grpc-ecosystem/go-grpc-middleware
logging/zap/ctxzap/context.go
AddFields
func AddFields(ctx context.Context, fields ...zapcore.Field) { l, ok := ctx.Value(ctxMarkerKey).(*ctxLogger) if !ok || l == nil { return } l.fields = append(l.fields, fields...) }
go
func AddFields(ctx context.Context, fields ...zapcore.Field) { l, ok := ctx.Value(ctxMarkerKey).(*ctxLogger) if !ok || l == nil { return } l.fields = append(l.fields, fields...) }
[ "func", "AddFields", "(", "ctx", "context", ".", "Context", ",", "fields", "...", "zapcore", ".", "Field", ")", "{", "l", ",", "ok", ":=", "ctx", ".", "Value", "(", "ctxMarkerKey", ")", ".", "(", "*", "ctxLogger", ")", "\n", "if", "!", "ok", "||", ...
// AddFields adds zap fields to the logger.
[ "AddFields", "adds", "zap", "fields", "to", "the", "logger", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/ctxzap/context.go#L23-L30
27,343
grpc-ecosystem/go-grpc-middleware
logging/zap/ctxzap/context.go
Extract
func Extract(ctx context.Context) *zap.Logger { l, ok := ctx.Value(ctxMarkerKey).(*ctxLogger) if !ok || l == nil { return nullLogger } // Add grpc_ctxtags tags metadata until now. fields := TagsToFields(ctx) // Add zap fields added until now. fields = append(fields, l.fields...) return l.logger.With(fields......
go
func Extract(ctx context.Context) *zap.Logger { l, ok := ctx.Value(ctxMarkerKey).(*ctxLogger) if !ok || l == nil { return nullLogger } // Add grpc_ctxtags tags metadata until now. fields := TagsToFields(ctx) // Add zap fields added until now. fields = append(fields, l.fields...) return l.logger.With(fields......
[ "func", "Extract", "(", "ctx", "context", ".", "Context", ")", "*", "zap", ".", "Logger", "{", "l", ",", "ok", ":=", "ctx", ".", "Value", "(", "ctxMarkerKey", ")", ".", "(", "*", "ctxLogger", ")", "\n", "if", "!", "ok", "||", "l", "==", "nil", ...
// Extract takes the call-scoped Logger from grpc_zap middleware. // // It always returns a Logger that has all the grpc_ctxtags updated.
[ "Extract", "takes", "the", "call", "-", "scoped", "Logger", "from", "grpc_zap", "middleware", ".", "It", "always", "returns", "a", "Logger", "that", "has", "all", "the", "grpc_ctxtags", "updated", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/ctxzap/context.go#L35-L45
27,344
grpc-ecosystem/go-grpc-middleware
logging/zap/ctxzap/context.go
TagsToFields
func TagsToFields(ctx context.Context) []zapcore.Field { fields := []zapcore.Field{} tags := grpc_ctxtags.Extract(ctx) for k, v := range tags.Values() { fields = append(fields, zap.Any(k, v)) } return fields }
go
func TagsToFields(ctx context.Context) []zapcore.Field { fields := []zapcore.Field{} tags := grpc_ctxtags.Extract(ctx) for k, v := range tags.Values() { fields = append(fields, zap.Any(k, v)) } return fields }
[ "func", "TagsToFields", "(", "ctx", "context", ".", "Context", ")", "[", "]", "zapcore", ".", "Field", "{", "fields", ":=", "[", "]", "zapcore", ".", "Field", "{", "}", "\n", "tags", ":=", "grpc_ctxtags", ".", "Extract", "(", "ctx", ")", "\n", "for",...
// TagsToFields transforms the Tags on the supplied context into zap fields.
[ "TagsToFields", "transforms", "the", "Tags", "on", "the", "supplied", "context", "into", "zap", "fields", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/ctxzap/context.go#L48-L55
27,345
grpc-ecosystem/go-grpc-middleware
logging/zap/ctxzap/context.go
ToContext
func ToContext(ctx context.Context, logger *zap.Logger) context.Context { l := &ctxLogger{ logger: logger, } return context.WithValue(ctx, ctxMarkerKey, l) }
go
func ToContext(ctx context.Context, logger *zap.Logger) context.Context { l := &ctxLogger{ logger: logger, } return context.WithValue(ctx, ctxMarkerKey, l) }
[ "func", "ToContext", "(", "ctx", "context", ".", "Context", ",", "logger", "*", "zap", ".", "Logger", ")", "context", ".", "Context", "{", "l", ":=", "&", "ctxLogger", "{", "logger", ":", "logger", ",", "}", "\n", "return", "context", ".", "WithValue",...
// ToContext adds the zap.Logger to the context for extraction later. // Returning the new context that has been created.
[ "ToContext", "adds", "the", "zap", ".", "Logger", "to", "the", "context", "for", "extraction", "later", ".", "Returning", "the", "new", "context", "that", "has", "been", "created", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/logging/zap/ctxzap/context.go#L59-L64
27,346
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/server_interceptors.go
UnaryServerInterceptor
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { if o.filterOutFunc != nil && !o.filterOutFunc(ctx, info.FullMethod) { return handler...
go
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { if o.filterOutFunc != nil && !o.filterOutFunc(ctx, info.FullMethod) { return handler...
[ "func", "UnaryServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "UnaryServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}",...
// UnaryServerInterceptor returns a new unary server interceptor for OpenTracing.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptor", "for", "OpenTracing", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/server_interceptors.go#L23-L34
27,347
grpc-ecosystem/go-grpc-middleware
tracing/opentracing/server_interceptors.go
StreamServerInterceptor
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { if o.filterOutFunc != nil && !o.filterOutFunc(stream.Context(), info.FullMethod) { return ...
go
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { if o.filterOutFunc != nil && !o.filterOutFunc(stream.Context(), info.FullMethod) { return ...
[ "func", "StreamServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "StreamServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "srv", "interface", "{", "}", ",", "stream", "grpc", ".", "ServerS...
// StreamServerInterceptor returns a new streaming server interceptor for OpenTracing.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "server", "interceptor", "for", "OpenTracing", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tracing/opentracing/server_interceptors.go#L37-L50
27,348
grpc-ecosystem/go-grpc-middleware
validator/validator.go
UnaryServerInterceptor
func UnaryServerInterceptor() grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { if v, ok := req.(validator); ok { if err := v.Validate(); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, err....
go
func UnaryServerInterceptor() grpc.UnaryServerInterceptor { return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { if v, ok := req.(validator); ok { if err := v.Validate(); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, err....
[ "func", "UnaryServerInterceptor", "(", ")", "grpc", ".", "UnaryServerInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}", ",", "info", "*", "grpc", ".", "UnaryServerInfo", ",", "handler", "grpc", ".",...
// UnaryServerInterceptor returns a new unary server interceptor that validates incoming messages. // // Invalid messages will be rejected with `InvalidArgument` before reaching any userspace handlers.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptor", "that", "validates", "incoming", "messages", ".", "Invalid", "messages", "will", "be", "rejected", "with", "InvalidArgument", "before", "reaching", "any", "userspace", "handlers", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/validator/validator.go#L19-L28
27,349
grpc-ecosystem/go-grpc-middleware
tags/interceptors.go
UnaryServerInterceptor
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { newCtx := newTagsForCtx(ctx) if o.requestFieldsFunc != nil { setRequestFieldTags(n...
go
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { o := evaluateOptions(opts) return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { newCtx := newTagsForCtx(ctx) if o.requestFieldsFunc != nil { setRequestFieldTags(n...
[ "func", "UnaryServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "UnaryServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}",...
// UnaryServerInterceptor returns a new unary server interceptors that sets the values for request tags.
[ "UnaryServerInterceptor", "returns", "a", "new", "unary", "server", "interceptors", "that", "sets", "the", "values", "for", "request", "tags", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tags/interceptors.go#L14-L23
27,350
grpc-ecosystem/go-grpc-middleware
tags/interceptors.go
StreamServerInterceptor
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { newCtx := newTagsForCtx(stream.Context()) if o.requestFieldsFunc == nil { // Short-circu...
go
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { o := evaluateOptions(opts) return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { newCtx := newTagsForCtx(stream.Context()) if o.requestFieldsFunc == nil { // Short-circu...
[ "func", "StreamServerInterceptor", "(", "opts", "...", "Option", ")", "grpc", ".", "StreamServerInterceptor", "{", "o", ":=", "evaluateOptions", "(", "opts", ")", "\n", "return", "func", "(", "srv", "interface", "{", "}", ",", "stream", "grpc", ".", "ServerS...
// StreamServerInterceptor returns a new streaming server interceptor that sets the values for request tags.
[ "StreamServerInterceptor", "returns", "a", "new", "streaming", "server", "interceptor", "that", "sets", "the", "values", "for", "request", "tags", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tags/interceptors.go#L26-L40
27,351
grpc-ecosystem/go-grpc-middleware
retry/backoff.go
BackoffExponential
func BackoffExponential(scalar time.Duration) BackoffFunc { return func(attempt uint) time.Duration { return scalar * time.Duration(backoffutils.ExponentBase2(attempt)) } }
go
func BackoffExponential(scalar time.Duration) BackoffFunc { return func(attempt uint) time.Duration { return scalar * time.Duration(backoffutils.ExponentBase2(attempt)) } }
[ "func", "BackoffExponential", "(", "scalar", "time", ".", "Duration", ")", "BackoffFunc", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "scalar", "*", "time", ".", "Duration", "(", "backoffutils", ".", "ExponentB...
// BackoffExponential produces increasing intervals for each attempt. // // The scalar is multiplied times 2 raised to the current attempt. So the first // retry with a scalar of 100ms is 100ms, while the 5th attempt would be 3.2s.
[ "BackoffExponential", "produces", "increasing", "intervals", "for", "each", "attempt", ".", "The", "scalar", "is", "multiplied", "times", "2", "raised", "to", "the", "current", "attempt", ".", "So", "the", "first", "retry", "with", "a", "scalar", "of", "100ms"...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/retry/backoff.go#L32-L36
27,352
grpc-ecosystem/go-grpc-middleware
retry/backoff.go
BackoffExponentialWithJitter
func BackoffExponentialWithJitter(scalar time.Duration, jitterFraction float64) BackoffFunc { return func(attempt uint) time.Duration { return backoffutils.JitterUp(scalar*time.Duration(backoffutils.ExponentBase2(attempt)), jitterFraction) } }
go
func BackoffExponentialWithJitter(scalar time.Duration, jitterFraction float64) BackoffFunc { return func(attempt uint) time.Duration { return backoffutils.JitterUp(scalar*time.Duration(backoffutils.ExponentBase2(attempt)), jitterFraction) } }
[ "func", "BackoffExponentialWithJitter", "(", "scalar", "time", ".", "Duration", ",", "jitterFraction", "float64", ")", "BackoffFunc", "{", "return", "func", "(", "attempt", "uint", ")", "time", ".", "Duration", "{", "return", "backoffutils", ".", "JitterUp", "("...
// BackoffExponentialWithJitter creates an exponential backoff like // BackoffExponential does, but adds jitter.
[ "BackoffExponentialWithJitter", "creates", "an", "exponential", "backoff", "like", "BackoffExponential", "does", "but", "adds", "jitter", "." ]
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/retry/backoff.go#L40-L44
27,353
grpc-ecosystem/go-grpc-middleware
tags/fieldextractor.go
CodeGenRequestFieldExtractor
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{} { if ext, ok := req.(requestFieldsExtractor); ok { retMap := make(map[string]interface{}) ext.ExtractRequestFields(retMap) if len(retMap) == 0 { return nil } return retMap } return nil }
go
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{} { if ext, ok := req.(requestFieldsExtractor); ok { retMap := make(map[string]interface{}) ext.ExtractRequestFields(retMap) if len(retMap) == 0 { return nil } return retMap } return nil }
[ "func", "CodeGenRequestFieldExtractor", "(", "fullMethod", "string", ",", "req", "interface", "{", "}", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "if", "ext", ",", "ok", ":=", "req", ".", "(", "requestFieldsExtractor", ")", ";", "ok", "...
// CodeGenRequestFieldExtractor is a function that relies on code-generated functions that export log fields from requests. // These are usually coming from a protoc-plugin that generates additional information based on custom field options.
[ "CodeGenRequestFieldExtractor", "is", "a", "function", "that", "relies", "on", "code", "-", "generated", "functions", "that", "export", "log", "fields", "from", "requests", ".", "These", "are", "usually", "coming", "from", "a", "protoc", "-", "plugin", "that", ...
cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/cfaf5686ec79ff8344257723b6f5ba1ae0ffeb4d/tags/fieldextractor.go#L23-L33
27,354
flynn/flynn
host/containerinit/init.go
changeState
func (c *ContainerInit) changeState(state State, err string, exitStatus int) { if err != "" { logger.Debug("changing state", "fn", "changeState", "state", state, "err", err) } else if exitStatus != -1 { logger.Debug("changing state", "fn", "changeState", "state", state, "exitStatus", exitStatus) } else { logge...
go
func (c *ContainerInit) changeState(state State, err string, exitStatus int) { if err != "" { logger.Debug("changing state", "fn", "changeState", "state", state, "err", err) } else if exitStatus != -1 { logger.Debug("changing state", "fn", "changeState", "state", state, "exitStatus", exitStatus) } else { logge...
[ "func", "(", "c", "*", "ContainerInit", ")", "changeState", "(", "state", "State", ",", "err", "string", ",", "exitStatus", "int", ")", "{", "if", "err", "!=", "\"", "\"", "{", "logger", ".", "Debug", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", ...
// Caller must hold lock
[ "Caller", "must", "hold", "lock" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L314-L332
27,355
flynn/flynn
host/containerinit/init.go
debugStackPrinter
func debugStackPrinter(out io.Writer) { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) for range c { pprof.Lookup("goroutine").WriteTo(out, 1) } }
go
func debugStackPrinter(out io.Writer) { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) for range c { pprof.Lookup("goroutine").WriteTo(out, 1) } }
[ "func", "debugStackPrinter", "(", "out", "io", ".", "Writer", ")", "{", "c", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "c", ",", "syscall", ".", "SIGUSR2", ")", "\n", "for", "range", "c", "...
// print a full goroutine stack trace to the log fd on SIGUSR2
[ "print", "a", "full", "goroutine", "stack", "trace", "to", "the", "log", "fd", "on", "SIGUSR2" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L754-L760
27,356
flynn/flynn
host/containerinit/init.go
Main
func Main() { logR, logW, err := newSocketPair("log") if err != nil { os.Exit(70) } go debugStackPrinter(logW) config := &Config{} data, err := ioutil.ReadFile("/.containerconfig") if err != nil { os.Exit(70) } if err := json.Unmarshal(data, config); err != nil { os.Exit(70) } logger = log15.New("com...
go
func Main() { logR, logW, err := newSocketPair("log") if err != nil { os.Exit(70) } go debugStackPrinter(logW) config := &Config{} data, err := ioutil.ReadFile("/.containerconfig") if err != nil { os.Exit(70) } if err := json.Unmarshal(data, config); err != nil { os.Exit(70) } logger = log15.New("com...
[ "func", "Main", "(", ")", "{", "logR", ",", "logW", ",", "err", ":=", "newSocketPair", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "os", ".", "Exit", "(", "70", ")", "\n", "}", "\n", "go", "debugStackPrinter", "(", "logW", ")", "...
// This code is run INSIDE the container and is responsible for setting // up the environment before running the actual process
[ "This", "code", "is", "run", "INSIDE", "the", "container", "and", "is", "responsible", "for", "setting", "up", "the", "environment", "before", "running", "the", "actual", "process" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/host/containerinit/init.go#L764-L789
27,357
flynn/flynn
pkg/iptables/iptables.go
Exists
func Exists(args ...string) bool { if _, err := Raw(append([]string{"-C"}, args...)...); err != nil { return false } return true }
go
func Exists(args ...string) bool { if _, err := Raw(append([]string{"-C"}, args...)...); err != nil { return false } return true }
[ "func", "Exists", "(", "args", "...", "string", ")", "bool", "{", "if", "_", ",", "err", ":=", "Raw", "(", "append", "(", "[", "]", "string", "{", "\"", "\"", "}", ",", "args", "...", ")", "...", ")", ";", "err", "!=", "nil", "{", "return", "...
// Check if an existing rule exists
[ "Check", "if", "an", "existing", "rule", "exists" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/iptables/iptables.go#L66-L71
27,358
flynn/flynn
appliance/mongodb/cmd.go
NewCmd
func NewCmd(cmd *exec.Cmd) *Cmd { c := &Cmd{ Cmd: cmd, stopped: make(chan struct{}, 1), } c.stoppingValue.Store(false) c.Stdout = os.Stdout c.Stderr = os.Stderr return c }
go
func NewCmd(cmd *exec.Cmd) *Cmd { c := &Cmd{ Cmd: cmd, stopped: make(chan struct{}, 1), } c.stoppingValue.Store(false) c.Stdout = os.Stdout c.Stderr = os.Stderr return c }
[ "func", "NewCmd", "(", "cmd", "*", "exec", ".", "Cmd", ")", "*", "Cmd", "{", "c", ":=", "&", "Cmd", "{", "Cmd", ":", "cmd", ",", "stopped", ":", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", ",", "}", "\n", "c", ".", "stoppingValue"...
// NewCmd returns a new instance of Cmd that wraps cmd.
[ "NewCmd", "returns", "a", "new", "instance", "of", "Cmd", "that", "wraps", "cmd", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L19-L28
27,359
flynn/flynn
appliance/mongodb/cmd.go
Start
func (cmd *Cmd) Start() error { if err := cmd.Cmd.Start(); err != nil { return err } go cmd.monitor() return nil }
go
func (cmd *Cmd) Start() error { if err := cmd.Cmd.Start(); err != nil { return err } go cmd.monitor() return nil }
[ "func", "(", "cmd", "*", "Cmd", ")", "Start", "(", ")", "error", "{", "if", "err", ":=", "cmd", ".", "Cmd", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "go", "cmd", ".", "monitor", "(", ")", "\n", ...
// Start executes the command.
[ "Start", "executes", "the", "command", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L31-L37
27,360
flynn/flynn
appliance/mongodb/cmd.go
Stop
func (cmd *Cmd) Stop() error { cmd.stoppingValue.Store(true) if err := cmd.Process.Signal(syscall.SIGKILL); err != nil { return err } return nil }
go
func (cmd *Cmd) Stop() error { cmd.stoppingValue.Store(true) if err := cmd.Process.Signal(syscall.SIGKILL); err != nil { return err } return nil }
[ "func", "(", "cmd", "*", "Cmd", ")", "Stop", "(", ")", "error", "{", "cmd", ".", "stoppingValue", ".", "Store", "(", "true", ")", "\n", "if", "err", ":=", "cmd", ".", "Process", ".", "Signal", "(", "syscall", ".", "SIGKILL", ")", ";", "err", "!="...
// Stop marks the command as expecting an exit and stops the underlying command.
[ "Stop", "marks", "the", "command", "as", "expecting", "an", "exit", "and", "stops", "the", "underlying", "command", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L40-L46
27,361
flynn/flynn
appliance/mongodb/cmd.go
monitor
func (cmd *Cmd) monitor() { err := cmd.Wait() if !cmd.stoppingValue.Load().(bool) { cmd.err = err } close(cmd.stopped) }
go
func (cmd *Cmd) monitor() { err := cmd.Wait() if !cmd.stoppingValue.Load().(bool) { cmd.err = err } close(cmd.stopped) }
[ "func", "(", "cmd", "*", "Cmd", ")", "monitor", "(", ")", "{", "err", ":=", "cmd", ".", "Wait", "(", ")", "\n", "if", "!", "cmd", ".", "stoppingValue", ".", "Load", "(", ")", ".", "(", "bool", ")", "{", "cmd", ".", "err", "=", "err", "\n", ...
// monitor checks for process exit and returns
[ "monitor", "checks", "for", "process", "exit", "and", "returns" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/mongodb/cmd.go#L56-L62
27,362
flynn/flynn
pkg/httpclient/json.go
Stream
func (c *Client) Stream(method, path string, in, out interface{}) (stream.Stream, error) { return c.StreamWithHeader(method, path, make(http.Header), in, out) }
go
func (c *Client) Stream(method, path string, in, out interface{}) (stream.Stream, error) { return c.StreamWithHeader(method, path, make(http.Header), in, out) }
[ "func", "(", "c", "*", "Client", ")", "Stream", "(", "method", ",", "path", "string", ",", "in", ",", "out", "interface", "{", "}", ")", "(", "stream", ".", "Stream", ",", "error", ")", "{", "return", "c", ".", "StreamWithHeader", "(", "method", ",...
// Stream returns a stream.Stream for a specific method and path. in is an // optional json object to be sent to the server via the body, and out is a // required channel, to which the output will be streamed.
[ "Stream", "returns", "a", "stream", ".", "Stream", "for", "a", "specific", "method", "and", "path", ".", "in", "is", "an", "optional", "json", "object", "to", "be", "sent", "to", "the", "server", "via", "the", "body", "and", "out", "is", "a", "required...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/httpclient/json.go#L222-L224
27,363
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextComponentName
func NewContextComponentName(ctx context.Context, componentName string) context.Context { return context.WithValue(ctx, ctxKeyComponent, componentName) }
go
func NewContextComponentName(ctx context.Context, componentName string) context.Context { return context.WithValue(ctx, ctxKeyComponent, componentName) }
[ "func", "NewContextComponentName", "(", "ctx", "context", ".", "Context", ",", "componentName", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyComponent", ",", "componentName", ")", "\n", "}" ]
// NewContextComponentName creates a new context that carries the provided // componentName value.
[ "NewContextComponentName", "creates", "a", "new", "context", "that", "carries", "the", "provided", "componentName", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L23-L25
27,364
flynn/flynn
pkg/ctxhelper/ctxhelper.go
ComponentNameFromContext
func ComponentNameFromContext(ctx context.Context) (componentName string, ok bool) { componentName, ok = ctx.Value(ctxKeyComponent).(string) return }
go
func ComponentNameFromContext(ctx context.Context) (componentName string, ok bool) { componentName, ok = ctx.Value(ctxKeyComponent).(string) return }
[ "func", "ComponentNameFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "componentName", "string", ",", "ok", "bool", ")", "{", "componentName", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyComponent", ")", ".", "(", "string", ")", "\n", ...
// ComponentNameFromContext extracts a component name from a context.
[ "ComponentNameFromContext", "extracts", "a", "component", "name", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L28-L31
27,365
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextLogger
func NewContextLogger(ctx context.Context, logger log.Logger) context.Context { return context.WithValue(ctx, ctxKeyLogger, logger) }
go
func NewContextLogger(ctx context.Context, logger log.Logger) context.Context { return context.WithValue(ctx, ctxKeyLogger, logger) }
[ "func", "NewContextLogger", "(", "ctx", "context", ".", "Context", ",", "logger", "log", ".", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyLogger", ",", "logger", ")", "\n", "}" ]
// NewContextLogger creates a new context that carries the provided logger // value.
[ "NewContextLogger", "creates", "a", "new", "context", "that", "carries", "the", "provided", "logger", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L35-L37
27,366
flynn/flynn
pkg/ctxhelper/ctxhelper.go
LoggerFromContext
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) { logger, ok = ctx.Value(ctxKeyLogger).(log.Logger) return }
go
func LoggerFromContext(ctx context.Context) (logger log.Logger, ok bool) { logger, ok = ctx.Value(ctxKeyLogger).(log.Logger) return }
[ "func", "LoggerFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "logger", "log", ".", "Logger", ",", "ok", "bool", ")", "{", "logger", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyLogger", ")", ".", "(", "log", ".", "Logger", ")", ...
// LoggerFromContext extracts a logger from a context.
[ "LoggerFromContext", "extracts", "a", "logger", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L40-L43
27,367
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextParams
func NewContextParams(ctx context.Context, params httprouter.Params) context.Context { return context.WithValue(ctx, ctxKeyParams, params) }
go
func NewContextParams(ctx context.Context, params httprouter.Params) context.Context { return context.WithValue(ctx, ctxKeyParams, params) }
[ "func", "NewContextParams", "(", "ctx", "context", ".", "Context", ",", "params", "httprouter", ".", "Params", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyParams", ",", "params", ")", "\n", "}" ]
// NewContextParams creates a new context that carries the provided params // value.
[ "NewContextParams", "creates", "a", "new", "context", "that", "carries", "the", "provided", "params", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L47-L49
27,368
flynn/flynn
pkg/ctxhelper/ctxhelper.go
ParamsFromContext
func ParamsFromContext(ctx context.Context) (params httprouter.Params, ok bool) { params, ok = ctx.Value(ctxKeyParams).(httprouter.Params) return }
go
func ParamsFromContext(ctx context.Context) (params httprouter.Params, ok bool) { params, ok = ctx.Value(ctxKeyParams).(httprouter.Params) return }
[ "func", "ParamsFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "params", "httprouter", ".", "Params", ",", "ok", "bool", ")", "{", "params", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyParams", ")", ".", "(", "httprouter", ".", "Par...
// ParamsFromContext extracts params from a context.
[ "ParamsFromContext", "extracts", "params", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L52-L55
27,369
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextRequestID
func NewContextRequestID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, ctxKeyReqID, id) }
go
func NewContextRequestID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, ctxKeyReqID, id) }
[ "func", "NewContextRequestID", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyReqID", ",", "id", ")", "\n", "}" ]
// NewContextRequestID creates a new context that carries the provided request // ID value.
[ "NewContextRequestID", "creates", "a", "new", "context", "that", "carries", "the", "provided", "request", "ID", "value", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L59-L61
27,370
flynn/flynn
pkg/ctxhelper/ctxhelper.go
RequestIDFromContext
func RequestIDFromContext(ctx context.Context) (id string, ok bool) { id, ok = ctx.Value(ctxKeyReqID).(string) return }
go
func RequestIDFromContext(ctx context.Context) (id string, ok bool) { id, ok = ctx.Value(ctxKeyReqID).(string) return }
[ "func", "RequestIDFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "id", "string", ",", "ok", "bool", ")", "{", "id", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyReqID", ")", ".", "(", "string", ")", "\n", "return", "\n", "}" ]
// RequestIDFromContext extracts a request ID from a context.
[ "RequestIDFromContext", "extracts", "a", "request", "ID", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L64-L67
27,371
flynn/flynn
pkg/ctxhelper/ctxhelper.go
NewContextStartTime
func NewContextStartTime(ctx context.Context, start time.Time) context.Context { return context.WithValue(ctx, ctxKeyStartTime, start) }
go
func NewContextStartTime(ctx context.Context, start time.Time) context.Context { return context.WithValue(ctx, ctxKeyStartTime, start) }
[ "func", "NewContextStartTime", "(", "ctx", "context", ".", "Context", ",", "start", "time", ".", "Time", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxKeyStartTime", ",", "start", ")", "\n", "}" ]
// NewContextStartTime creates a new context that carries the provided start // time.
[ "NewContextStartTime", "creates", "a", "new", "context", "that", "carries", "the", "provided", "start", "time", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L71-L73
27,372
flynn/flynn
pkg/ctxhelper/ctxhelper.go
StartTimeFromContext
func StartTimeFromContext(ctx context.Context) (start time.Time, ok bool) { start, ok = ctx.Value(ctxKeyStartTime).(time.Time) return }
go
func StartTimeFromContext(ctx context.Context) (start time.Time, ok bool) { start, ok = ctx.Value(ctxKeyStartTime).(time.Time) return }
[ "func", "StartTimeFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "start", "time", ".", "Time", ",", "ok", "bool", ")", "{", "start", ",", "ok", "=", "ctx", ".", "Value", "(", "ctxKeyStartTime", ")", ".", "(", "time", ".", "Time", ")",...
// StartTimeFromContext extracts a start time from a context.
[ "StartTimeFromContext", "extracts", "a", "start", "time", "from", "a", "context", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/ctxhelper/ctxhelper.go#L76-L79
27,373
flynn/flynn
controller/sink.go
CreateSink
func (c *controllerAPI) CreateSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { var sink ct.Sink if err := httphelper.DecodeJSON(req, &sink); err != nil { respondWithError(w, err) return } if err := schema.Validate(&sink); err != nil { respondWithError(w, err) return } if err := c.si...
go
func (c *controllerAPI) CreateSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { var sink ct.Sink if err := httphelper.DecodeJSON(req, &sink); err != nil { respondWithError(w, err) return } if err := schema.Validate(&sink); err != nil { respondWithError(w, err) return } if err := c.si...
[ "func", "(", "c", "*", "controllerAPI", ")", "CreateSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "var", "sink", "ct", ".", "Sink", "\n", "if", "err", ":=", ...
// Create a new sink
[ "Create", "a", "new", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L132-L149
27,374
flynn/flynn
controller/sink.go
GetSink
func (c *controllerAPI) GetSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sink, err := c.sinkRepo.Get(params.ByName("sink_id")) if err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
go
func (c *controllerAPI) GetSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sink, err := c.sinkRepo.Get(params.ByName("sink_id")) if err != nil { respondWithError(w, err) return } httphelper.JSON(w, 200, sink) }
[ "func", "(", "c", "*", "controllerAPI", ")", "GetSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ",", "_", ":=", "ctxhelper", ".", "ParamsFromContext", ...
// Get a sink
[ "Get", "a", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L152-L162
27,375
flynn/flynn
controller/sink.go
DeleteSink
func (c *controllerAPI) DeleteSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sinkID := params.ByName("sink_id") sink, err := c.sinkRepo.Get(sinkID) if err != nil { respondWithError(w, err) return } if err = c.sinkRepo.Remove(sinkID); err !...
go
func (c *controllerAPI) DeleteSink(ctx context.Context, w http.ResponseWriter, req *http.Request) { params, _ := ctxhelper.ParamsFromContext(ctx) sinkID := params.ByName("sink_id") sink, err := c.sinkRepo.Get(sinkID) if err != nil { respondWithError(w, err) return } if err = c.sinkRepo.Remove(sinkID); err !...
[ "func", "(", "c", "*", "controllerAPI", ")", "DeleteSink", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "params", ",", "_", ":=", "ctxhelper", ".", "ParamsFromContext",...
// Delete a sink
[ "Delete", "a", "sink" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/sink.go#L261-L277
27,376
flynn/flynn
util/release/types/manifest.go
Add
func (m *EC2Manifest) Add(version string, image *EC2Image) { versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { images := make([]*EC2Image, len(v.Images)) added := false for n, i := range v.Images { if i.Region == image.Region { // repla...
go
func (m *EC2Manifest) Add(version string, image *EC2Image) { versions := make(sortVersions, 0, len(m.Versions)+1) for _, v := range m.Versions { if v.version() == version { images := make([]*EC2Image, len(v.Images)) added := false for n, i := range v.Images { if i.Region == image.Region { // repla...
[ "func", "(", "m", "*", "EC2Manifest", ")", "Add", "(", "version", "string", ",", "image", "*", "EC2Image", ")", "{", "versions", ":=", "make", "(", "sortVersions", ",", "0", ",", "len", "(", "m", ".", "Versions", ")", "+", "1", ")", "\n", "for", ...
// Add adds an image to the manifest. // // If the version is already in the manifest, the given image either // replaces any existing image with the same region, or is appended to // the existing list of images for that version. // // If the version is not already in the manifest a new version is added // containing t...
[ "Add", "adds", "an", "image", "to", "the", "manifest", ".", "If", "the", "version", "is", "already", "in", "the", "manifest", "the", "given", "image", "either", "replaces", "any", "existing", "image", "with", "the", "same", "region", "or", "is", "appended"...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/util/release/types/manifest.go#L26-L58
27,377
flynn/flynn
util/release/types/manifest.go
Add
func (m *VagrantManifest) Add(version string, provider *VagrantProvider) { // strip the leading "v" from the version as Vagrant only supports // versions like X.Y.Z, see https://github.com/flynn/flynn/issues/2230 version = strings.TrimPrefix(version, "v") versions := make(sortVersions, 0, len(m.Versions)+1) for _...
go
func (m *VagrantManifest) Add(version string, provider *VagrantProvider) { // strip the leading "v" from the version as Vagrant only supports // versions like X.Y.Z, see https://github.com/flynn/flynn/issues/2230 version = strings.TrimPrefix(version, "v") versions := make(sortVersions, 0, len(m.Versions)+1) for _...
[ "func", "(", "m", "*", "VagrantManifest", ")", "Add", "(", "version", "string", ",", "provider", "*", "VagrantProvider", ")", "{", "// strip the leading \"v\" from the version as Vagrant only supports", "// versions like X.Y.Z, see https://github.com/flynn/flynn/issues/2230", "ve...
// Add adds a provider to the manifest. // // If the version is already in the manifest, the given provider either // replaces any existing provider with the same name, or is appended to // the existing list of providers for that version. // // If the version is not already in the manifest a new version is added // con...
[ "Add", "adds", "a", "provider", "to", "the", "manifest", ".", "If", "the", "version", "is", "already", "in", "the", "manifest", "the", "given", "provider", "either", "replaces", "any", "existing", "provider", "with", "the", "same", "name", "or", "is", "app...
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/util/release/types/manifest.go#L114-L150
27,378
flynn/flynn
pkg/mux/mux.go
New
func New(ln net.Listener) *Mux { return &Mux{ ln: ln, handlers: make(map[byte]*handler), Timeout: 30 * time.Second, LogOutput: os.Stderr, } }
go
func New(ln net.Listener) *Mux { return &Mux{ ln: ln, handlers: make(map[byte]*handler), Timeout: 30 * time.Second, LogOutput: os.Stderr, } }
[ "func", "New", "(", "ln", "net", ".", "Listener", ")", "*", "Mux", "{", "return", "&", "Mux", "{", "ln", ":", "ln", ",", "handlers", ":", "make", "(", "map", "[", "byte", "]", "*", "handler", ")", ",", "Timeout", ":", "30", "*", "time", ".", ...
// New returns a new instance of Mux.
[ "New", "returns", "a", "new", "instance", "of", "Mux", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L29-L36
27,379
flynn/flynn
pkg/mux/mux.go
Close
func (mux *Mux) Close() (err error) { mux.once.Do(func() { // Close underlying listener. if mux.ln != nil { err = mux.ln.Close() } // Wait for open connections to close and then close handlers. mux.wg.Wait() for _, h := range mux.handlers { h.Close() } }) return }
go
func (mux *Mux) Close() (err error) { mux.once.Do(func() { // Close underlying listener. if mux.ln != nil { err = mux.ln.Close() } // Wait for open connections to close and then close handlers. mux.wg.Wait() for _, h := range mux.handlers { h.Close() } }) return }
[ "func", "(", "mux", "*", "Mux", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "mux", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "// Close underlying listener.", "if", "mux", ".", "ln", "!=", "nil", "{", "err", "=", "mux", ".", ...
// Close closes the underlying listener.
[ "Close", "closes", "the", "underlying", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L39-L53
27,380
flynn/flynn
pkg/mux/mux.go
Serve
func (mux *Mux) Serve() error { logger := log.New(mux.LogOutput, "", log.LstdFlags) for { // Handle incoming connections. Retry temporary errors. conn, err := mux.ln.Accept() if err, ok := err.(interface { Temporary() bool }); ok && err.Temporary() { logger.Printf("tcp.Mux: temporary error: %s", err) ...
go
func (mux *Mux) Serve() error { logger := log.New(mux.LogOutput, "", log.LstdFlags) for { // Handle incoming connections. Retry temporary errors. conn, err := mux.ln.Accept() if err, ok := err.(interface { Temporary() bool }); ok && err.Temporary() { logger.Printf("tcp.Mux: temporary error: %s", err) ...
[ "func", "(", "mux", "*", "Mux", ")", "Serve", "(", ")", "error", "{", "logger", ":=", "log", ".", "New", "(", "mux", ".", "LogOutput", ",", "\"", "\"", ",", "log", ".", "LstdFlags", ")", "\n\n", "for", "{", "// Handle incoming connections. Retry temporar...
// Serve handles connections from ln and multiplexes then across registered listener.
[ "Serve", "handles", "connections", "from", "ln", "and", "multiplexes", "then", "across", "registered", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L56-L85
27,381
flynn/flynn
pkg/mux/mux.go
Listen
func (mux *Mux) Listen(hdrs []byte) net.Listener { // Create new handler. h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h }
go
func (mux *Mux) Listen(hdrs []byte) net.Listener { // Create new handler. h := mux.handler() // Register each header byte. for _, hdr := range hdrs { // Create a new listener and assign it. mux.handlers[hdr] = h } return h }
[ "func", "(", "mux", "*", "Mux", ")", "Listen", "(", "hdrs", "[", "]", "byte", ")", "net", ".", "Listener", "{", "// Create new handler.", "h", ":=", "mux", ".", "handler", "(", ")", "\n\n", "// Register each header byte.", "for", "_", ",", "hdr", ":=", ...
// Listen returns a listener that receives connections from any byte in hdrs. // Re-registering hdr bytes will overwrite existing handlers.
[ "Listen", "returns", "a", "listener", "that", "receives", "connections", "from", "any", "byte", "in", "hdrs", ".", "Re", "-", "registering", "hdr", "bytes", "will", "overwrite", "existing", "handlers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L122-L133
27,382
flynn/flynn
pkg/mux/mux.go
handler
func (mux *Mux) handler() *handler { return &handler{ mux: mux, c: make(chan net.Conn), } }
go
func (mux *Mux) handler() *handler { return &handler{ mux: mux, c: make(chan net.Conn), } }
[ "func", "(", "mux", "*", "Mux", ")", "handler", "(", ")", "*", "handler", "{", "return", "&", "handler", "{", "mux", ":", "mux", ",", "c", ":", "make", "(", "chan", "net", ".", "Conn", ")", ",", "}", "\n", "}" ]
// handler returns a new instance of handler.
[ "handler", "returns", "a", "new", "instance", "of", "handler", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L136-L141
27,383
flynn/flynn
pkg/mux/mux.go
Accept
func (h *handler) Accept() (c net.Conn, err error) { conn, ok := <-h.c if !ok { return nil, errors.New("network connection closed") } return conn, nil }
go
func (h *handler) Accept() (c net.Conn, err error) { conn, ok := <-h.c if !ok { return nil, errors.New("network connection closed") } return conn, nil }
[ "func", "(", "h", "*", "handler", ")", "Accept", "(", ")", "(", "c", "net", ".", "Conn", ",", "err", "error", ")", "{", "conn", ",", "ok", ":=", "<-", "h", ".", "c", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(...
// Accept waits for and returns the next connection.
[ "Accept", "waits", "for", "and", "returns", "the", "next", "connection", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L151-L157
27,384
flynn/flynn
pkg/mux/mux.go
Close
func (h *handler) Close() error { h.once.Do(func() { close(h.c) }) return nil }
go
func (h *handler) Close() error { h.once.Do(func() { close(h.c) }) return nil }
[ "func", "(", "h", "*", "handler", ")", "Close", "(", ")", "error", "{", "h", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "h", ".", "c", ")", "}", ")", "\n", "return", "nil", "\n", "}" ]
// Close closes the original listener.
[ "Close", "closes", "the", "original", "listener", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L160-L163
27,385
flynn/flynn
pkg/mux/mux.go
newBufConn
func newBufConn(conn net.Conn) *bufConn { return &bufConn{ conn: conn, r: bufio.NewReader(conn), } }
go
func newBufConn(conn net.Conn) *bufConn { return &bufConn{ conn: conn, r: bufio.NewReader(conn), } }
[ "func", "newBufConn", "(", "conn", "net", ".", "Conn", ")", "*", "bufConn", "{", "return", "&", "bufConn", "{", "conn", ":", "conn", ",", "r", ":", "bufio", ".", "NewReader", "(", "conn", ")", ",", "}", "\n", "}" ]
// newBufConn returns a new instance of bufConn.
[ "newBufConn", "returns", "a", "new", "instance", "of", "bufConn", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/mux/mux.go#L175-L180
27,386
flynn/flynn
controller/worker/deployment/discoverd_meta.go
deployDiscoverdMeta
func (d *DeployJob) deployDiscoverdMeta() (err error) { log := d.logger.New("fn", "deployDiscoverdMeta") log.Info("starting discoverd-meta deployment") defer func() { if err != nil { // TODO: support rolling back err = ErrSkipRollback{err.Error()} } }() for typ, count := range d.Processes { proc := d...
go
func (d *DeployJob) deployDiscoverdMeta() (err error) { log := d.logger.New("fn", "deployDiscoverdMeta") log.Info("starting discoverd-meta deployment") defer func() { if err != nil { // TODO: support rolling back err = ErrSkipRollback{err.Error()} } }() for typ, count := range d.Processes { proc := d...
[ "func", "(", "d", "*", "DeployJob", ")", "deployDiscoverdMeta", "(", ")", "(", "err", "error", ")", "{", "log", ":=", "d", ".", "logger", ".", "New", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "log", ".", "Info", "(", "\"", "\"", ")", "\n\n",...
// deployDiscoverMeta does a one-by-one deployment but uses discoverd.Deployment // to wait for appropriate service metadata before stopping old jobs.
[ "deployDiscoverMeta", "does", "a", "one", "-", "by", "-", "one", "deployment", "but", "uses", "discoverd", ".", "Deployment", "to", "wait", "for", "appropriate", "service", "metadata", "before", "stopping", "old", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/worker/deployment/discoverd_meta.go#L7-L50
27,387
flynn/flynn
logaggregator/client/client.go
NewWithHTTP
func NewWithHTTP(uri string, httpClient *http.Client) (*Client, error) { if uri == "" { uri = "http://logaggregator.discoverd" } u, err := url.Parse(uri) if err != nil { return nil, err } return newClient(u.String(), httpClient), nil }
go
func NewWithHTTP(uri string, httpClient *http.Client) (*Client, error) { if uri == "" { uri = "http://logaggregator.discoverd" } u, err := url.Parse(uri) if err != nil { return nil, err } return newClient(u.String(), httpClient), nil }
[ "func", "NewWithHTTP", "(", "uri", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "uri", "==", "\"", "\"", "{", "uri", "=", "\"", "\"", "\n", "}", "\n", "u", ",", "err", ":=", "ur...
// NewClient creates a new Client pointing at uri with the specified http client.
[ "NewClient", "creates", "a", "new", "Client", "pointing", "at", "uri", "with", "the", "specified", "http", "client", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/client/client.go#L42-L51
27,388
flynn/flynn
pkg/rpcplus/jsonrpc/client.go
NewClientCodec
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec { return &clientCodec{ dec: json.NewDecoder(conn), enc: json.NewEncoder(conn), c: conn, pending: make(map[uint64]string), } }
go
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec { return &clientCodec{ dec: json.NewDecoder(conn), enc: json.NewEncoder(conn), c: conn, pending: make(map[uint64]string), } }
[ "func", "NewClientCodec", "(", "conn", "io", ".", "ReadWriteCloser", ")", "rpc", ".", "ClientCodec", "{", "return", "&", "clientCodec", "{", "dec", ":", "json", ".", "NewDecoder", "(", "conn", ")", ",", "enc", ":", "json", ".", "NewEncoder", "(", "conn",...
// NewClientCodec returns a new rpc.ClientCodec using JSON-RPC on conn.
[ "NewClientCodec", "returns", "a", "new", "rpc", ".", "ClientCodec", "using", "JSON", "-", "RPC", "on", "conn", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/client.go#L37-L44
27,389
flynn/flynn
pkg/rpcplus/jsonrpc/client.go
NewClient
func NewClient(conn io.ReadWriteCloser) *rpc.Client { return rpc.NewClientWithCodec(NewClientCodec(conn)) }
go
func NewClient(conn io.ReadWriteCloser) *rpc.Client { return rpc.NewClientWithCodec(NewClientCodec(conn)) }
[ "func", "NewClient", "(", "conn", "io", ".", "ReadWriteCloser", ")", "*", "rpc", ".", "Client", "{", "return", "rpc", ".", "NewClientWithCodec", "(", "NewClientCodec", "(", "conn", ")", ")", "\n", "}" ]
// NewClient returns a new rpc.Client to handle requests to the // set of services at the other end of the connection.
[ "NewClient", "returns", "a", "new", "rpc", ".", "Client", "to", "handle", "requests", "to", "the", "set", "of", "services", "at", "the", "other", "end", "of", "the", "connection", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/rpcplus/jsonrpc/client.go#L113-L115
27,390
flynn/flynn
controller/types/types.go
Critical
func (a *App) Critical() bool { v, ok := a.Meta["flynn-system-critical"] return ok && v == "true" }
go
func (a *App) Critical() bool { v, ok := a.Meta["flynn-system-critical"] return ok && v == "true" }
[ "func", "(", "a", "*", "App", ")", "Critical", "(", ")", "bool", "{", "v", ",", "ok", ":=", "a", ".", "Meta", "[", "\"", "\"", "]", "\n", "return", "ok", "&&", "v", "==", "\"", "\"", "\n", "}" ]
// Critical apps cannot be completely scaled down by the scheduler
[ "Critical", "apps", "cannot", "be", "completely", "scaled", "down", "by", "the", "scheduler" ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/types/types.go#L74-L77
27,391
flynn/flynn
pkg/syslog/rfc5424/message.go
NewMessage
func NewMessage(hdr *Header, msg []byte) *Message { var h Header if hdr != nil { h = *hdr } if h.Timestamp.IsZero() { h.Timestamp = time.Now().UTC() } if h.Version == 0 { h.Version = 1 } if msg != nil { m := make([]byte, len(msg)) copy(m, msg) msg = m } return &Message{Header: h, Msg: msg} }
go
func NewMessage(hdr *Header, msg []byte) *Message { var h Header if hdr != nil { h = *hdr } if h.Timestamp.IsZero() { h.Timestamp = time.Now().UTC() } if h.Version == 0 { h.Version = 1 } if msg != nil { m := make([]byte, len(msg)) copy(m, msg) msg = m } return &Message{Header: h, Msg: msg} }
[ "func", "NewMessage", "(", "hdr", "*", "Header", ",", "msg", "[", "]", "byte", ")", "*", "Message", "{", "var", "h", "Header", "\n", "if", "hdr", "!=", "nil", "{", "h", "=", "*", "hdr", "\n", "}", "\n\n", "if", "h", ".", "Timestamp", ".", "IsZe...
// NewMessage builds a new message from a copy of the header and message.
[ "NewMessage", "builds", "a", "new", "message", "from", "a", "copy", "of", "the", "header", "and", "message", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/pkg/syslog/rfc5424/message.go#L23-L44
27,392
flynn/flynn
controller/scheduler/host.go
StreamJobEventsTo
func (h *Host) StreamJobEventsTo(ch chan *host.Event) (map[string]host.ActiveJob, error) { log := h.logger.New("fn", "StreamJobEventsTo", "host.id", h.ID) var events chan *host.Event var stream stream.Stream connect := func() (err error) { log.Info("connecting job event stream") events = make(chan *host.Event) ...
go
func (h *Host) StreamJobEventsTo(ch chan *host.Event) (map[string]host.ActiveJob, error) { log := h.logger.New("fn", "StreamJobEventsTo", "host.id", h.ID) var events chan *host.Event var stream stream.Stream connect := func() (err error) { log.Info("connecting job event stream") events = make(chan *host.Event) ...
[ "func", "(", "h", "*", "Host", ")", "StreamJobEventsTo", "(", "ch", "chan", "*", "host", ".", "Event", ")", "(", "map", "[", "string", "]", "host", ".", "ActiveJob", ",", "error", ")", "{", "log", ":=", "h", ".", "logger", ".", "New", "(", "\"", ...
// StreamJobEventsTo streams all job events from the host to the given channel // in a goroutine, returning the current list of active jobs.
[ "StreamJobEventsTo", "streams", "all", "job", "events", "from", "the", "host", "to", "the", "given", "channel", "in", "a", "goroutine", "returning", "the", "current", "list", "of", "active", "jobs", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/controller/scheduler/host.go#L153-L219
27,393
flynn/flynn
logaggregator/snapshot/snapshot.go
WriteTo
func WriteTo(buffers [][]*rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) return writeTo(buffers, enc) }
go
func WriteTo(buffers [][]*rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) return writeTo(buffers, enc) }
[ "func", "WriteTo", "(", "buffers", "[", "]", "[", "]", "*", "rfc5424", ".", "Message", ",", "w", "io", ".", "Writer", ")", "error", "{", "enc", ":=", "gob", ".", "NewEncoder", "(", "w", ")", "\n", "return", "writeTo", "(", "buffers", ",", "enc", ...
// WriteTo writes a snapshot of the buffers to the writer. The partitioning of // messages is not retained. The writer is left open.
[ "WriteTo", "writes", "a", "snapshot", "of", "the", "buffers", "to", "the", "writer", ".", "The", "partitioning", "of", "messages", "is", "not", "retained", ".", "The", "writer", "is", "left", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L12-L15
27,394
flynn/flynn
logaggregator/snapshot/snapshot.go
StreamTo
func StreamTo(buffers [][]*rfc5424.Message, msgc <-chan *rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) if err := writeTo(buffers, enc); err != nil { return err } for msg := range msgc { if err := enc.Encode(msg); err != nil { return err } } return nil }
go
func StreamTo(buffers [][]*rfc5424.Message, msgc <-chan *rfc5424.Message, w io.Writer) error { enc := gob.NewEncoder(w) if err := writeTo(buffers, enc); err != nil { return err } for msg := range msgc { if err := enc.Encode(msg); err != nil { return err } } return nil }
[ "func", "StreamTo", "(", "buffers", "[", "]", "[", "]", "*", "rfc5424", ".", "Message", ",", "msgc", "<-", "chan", "*", "rfc5424", ".", "Message", ",", "w", "io", ".", "Writer", ")", "error", "{", "enc", ":=", "gob", ".", "NewEncoder", "(", "w", ...
// StreamTo writes a snapshot of the buffers to the writer, then writes // messages from the channel to the writer. The writer is left open.
[ "StreamTo", "writes", "a", "snapshot", "of", "the", "buffers", "to", "the", "writer", "then", "writes", "messages", "from", "the", "channel", "to", "the", "writer", ".", "The", "writer", "is", "left", "open", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L30-L42
27,395
flynn/flynn
logaggregator/snapshot/snapshot.go
NewScanner
func NewScanner(r io.Reader) *Scanner { return &Scanner{dec: gob.NewDecoder(r)} }
go
func NewScanner(r io.Reader) *Scanner { return &Scanner{dec: gob.NewDecoder(r)} }
[ "func", "NewScanner", "(", "r", "io", ".", "Reader", ")", "*", "Scanner", "{", "return", "&", "Scanner", "{", "dec", ":", "gob", ".", "NewDecoder", "(", "r", ")", "}", "\n", "}" ]
// NewScanner returns a new Scanner reading from r.
[ "NewScanner", "returns", "a", "new", "Scanner", "reading", "from", "r", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/logaggregator/snapshot/snapshot.go#L53-L55
27,396
flynn/flynn
appliance/redis/handler.go
healthStatus
func (h *Handler) healthStatus() status.Status { info, err := h.Process.Info() if err != nil || !info.Running { return status.Unhealthy } return status.Healthy }
go
func (h *Handler) healthStatus() status.Status { info, err := h.Process.Info() if err != nil || !info.Running { return status.Unhealthy } return status.Healthy }
[ "func", "(", "h", "*", "Handler", ")", "healthStatus", "(", ")", "status", ".", "Status", "{", "info", ",", "err", ":=", "h", ".", "Process", ".", "Info", "(", ")", "\n", "if", "err", "!=", "nil", "||", "!", "info", ".", "Running", "{", "return",...
// healthStatus returns whether the process is healthy or unhealthy.
[ "healthStatus", "returns", "whether", "the", "process", "is", "healthy", "or", "unhealthy", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/appliance/redis/handler.go#L38-L44
27,397
flynn/flynn
discoverd/main.go
Promote
func (m *Main) Promote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Printf("attempting promotion") // Request the leader joins us to the cluster. m.logger.Println("requesting leader join us to cluster") targetLogIndex, err := discoverd.DefaultClient.RaftAddPeer(m.advertiseAddr) if err != nil { m.logger...
go
func (m *Main) Promote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Printf("attempting promotion") // Request the leader joins us to the cluster. m.logger.Println("requesting leader join us to cluster") targetLogIndex, err := discoverd.DefaultClient.RaftAddPeer(m.advertiseAddr) if err != nil { m.logger...
[ "func", "(", "m", "*", "Main", ")", "Promote", "(", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "m", ".", "logger", ".", "Printf", "(", "\"", "\"", ")", "\n\n", "...
// Join the consensus set, promoting ourselves from proxy to raft node.
[ "Join", "the", "consensus", "set", "promoting", "ourselves", "from", "proxy", "to", "raft", "node", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L289-L332
27,398
flynn/flynn
discoverd/main.go
Demote
func (m *Main) Demote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("demotion requested") var leaderAddr string if m.store != nil { leaderAddr := m.store.Leader() if leaderAddr == "" { return server.ErrNoKnownLeader } } else { leader, err := discoverd.DefaultClient.RaftLeader() if err ...
go
func (m *Main) Demote() error { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("demotion requested") var leaderAddr string if m.store != nil { leaderAddr := m.store.Leader() if leaderAddr == "" { return server.ErrNoKnownLeader } } else { leader, err := discoverd.DefaultClient.RaftLeader() if err ...
[ "func", "(", "m", "*", "Main", ")", "Demote", "(", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "m", ".", "logger", ".", "Println", "(", "\"", "\"", ")", "\n\n", "...
// Leave the consensus set, demoting ourselves to proxy from raft node.
[ "Leave", "the", "consensus", "set", "demoting", "ourselves", "to", "proxy", "from", "raft", "node", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L335-L394
27,399
flynn/flynn
discoverd/main.go
Close
func (m *Main) Close() (info dt.TargetLogIndex, err error) { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("discoverd shutting down") if m.httpServer != nil { // Disable keep alives so that persistent connections will close m.httpServer.SetKeepAlivesEnabled(false) } if m.dnsServer != nil { m.dnsServer.Cl...
go
func (m *Main) Close() (info dt.TargetLogIndex, err error) { m.mu.Lock() defer m.mu.Unlock() m.logger.Println("discoverd shutting down") if m.httpServer != nil { // Disable keep alives so that persistent connections will close m.httpServer.SetKeepAlivesEnabled(false) } if m.dnsServer != nil { m.dnsServer.Cl...
[ "func", "(", "m", "*", "Main", ")", "Close", "(", ")", "(", "info", "dt", ".", "TargetLogIndex", ",", "err", "error", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "m", ".", "...
// Close shuts down all open servers.
[ "Close", "shuts", "down", "all", "open", "servers", "." ]
b4b05fce92da5fbc53b272362d87b994b88a3869
https://github.com/flynn/flynn/blob/b4b05fce92da5fbc53b272362d87b994b88a3869/discoverd/main.go#L407-L428