id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
127,000
grpc/grpc-go
server.go
KeepaliveParams
func KeepaliveParams(kp keepalive.ServerParameters) ServerOption { if kp.Time > 0 && kp.Time < time.Second { grpclog.Warning("Adjusting keepalive ping interval to minimum period of 1s") kp.Time = time.Second } return newFuncServerOption(func(o *serverOptions) { o.keepaliveParams = kp }) }
go
func KeepaliveParams(kp keepalive.ServerParameters) ServerOption { if kp.Time > 0 && kp.Time < time.Second { grpclog.Warning("Adjusting keepalive ping interval to minimum period of 1s") kp.Time = time.Second } return newFuncServerOption(func(o *serverOptions) { o.keepaliveParams = kp }) }
[ "func", "KeepaliveParams", "(", "kp", "keepalive", ".", "ServerParameters", ")", "ServerOption", "{", "if", "kp", ".", "Time", ">", "0", "&&", "kp", ".", "Time", "<", "time", ".", "Second", "{", "grpclog", ".", "Warning", "(", "\"", "\"", ")", "\n", ...
// KeepaliveParams returns a ServerOption that sets keepalive and max-age parameters for the server.
[ "KeepaliveParams", "returns", "a", "ServerOption", "that", "sets", "keepalive", "and", "max", "-", "age", "parameters", "for", "the", "server", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L210-L219
127,001
grpc/grpc-go
server.go
KeepaliveEnforcementPolicy
func KeepaliveEnforcementPolicy(kep keepalive.EnforcementPolicy) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.keepalivePolicy = kep }) }
go
func KeepaliveEnforcementPolicy(kep keepalive.EnforcementPolicy) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.keepalivePolicy = kep }) }
[ "func", "KeepaliveEnforcementPolicy", "(", "kep", "keepalive", ".", "EnforcementPolicy", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "keepalivePolicy", "=", "kep", "\n", "}", ")", ...
// KeepaliveEnforcementPolicy returns a ServerOption that sets keepalive enforcement policy for the server.
[ "KeepaliveEnforcementPolicy", "returns", "a", "ServerOption", "that", "sets", "keepalive", "enforcement", "policy", "for", "the", "server", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L222-L226
127,002
grpc/grpc-go
server.go
CustomCodec
func CustomCodec(codec Codec) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.codec = codec }) }
go
func CustomCodec(codec Codec) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.codec = codec }) }
[ "func", "CustomCodec", "(", "codec", "Codec", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "codec", "=", "codec", "\n", "}", ")", "\n", "}" ]
// CustomCodec returns a ServerOption that sets a codec for message marshaling and unmarshaling. // // This will override any lookups by content-subtype for Codecs registered with RegisterCodec.
[ "CustomCodec", "returns", "a", "ServerOption", "that", "sets", "a", "codec", "for", "message", "marshaling", "and", "unmarshaling", ".", "This", "will", "override", "any", "lookups", "by", "content", "-", "subtype", "for", "Codecs", "registered", "with", "Regist...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L231-L235
127,003
grpc/grpc-go
server.go
MaxRecvMsgSize
func MaxRecvMsgSize(m int) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxReceiveMessageSize = m }) }
go
func MaxRecvMsgSize(m int) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxReceiveMessageSize = m }) }
[ "func", "MaxRecvMsgSize", "(", "m", "int", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "maxReceiveMessageSize", "=", "m", "\n", "}", ")", "\n", "}" ]
// MaxRecvMsgSize returns a ServerOption to set the max message size in bytes the server can receive. // If this is not set, gRPC uses the default 4MB.
[ "MaxRecvMsgSize", "returns", "a", "ServerOption", "to", "set", "the", "max", "message", "size", "in", "bytes", "the", "server", "can", "receive", ".", "If", "this", "is", "not", "set", "gRPC", "uses", "the", "default", "4MB", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L271-L275
127,004
grpc/grpc-go
server.go
MaxSendMsgSize
func MaxSendMsgSize(m int) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxSendMessageSize = m }) }
go
func MaxSendMsgSize(m int) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxSendMessageSize = m }) }
[ "func", "MaxSendMsgSize", "(", "m", "int", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "maxSendMessageSize", "=", "m", "\n", "}", ")", "\n", "}" ]
// MaxSendMsgSize returns a ServerOption to set the max message size in bytes the server can send. // If this is not set, gRPC uses the default `math.MaxInt32`.
[ "MaxSendMsgSize", "returns", "a", "ServerOption", "to", "set", "the", "max", "message", "size", "in", "bytes", "the", "server", "can", "send", ".", "If", "this", "is", "not", "set", "gRPC", "uses", "the", "default", "math", ".", "MaxInt32", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L279-L283
127,005
grpc/grpc-go
server.go
MaxConcurrentStreams
func MaxConcurrentStreams(n uint32) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxConcurrentStreams = n }) }
go
func MaxConcurrentStreams(n uint32) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.maxConcurrentStreams = n }) }
[ "func", "MaxConcurrentStreams", "(", "n", "uint32", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "maxConcurrentStreams", "=", "n", "\n", "}", ")", "\n", "}" ]
// MaxConcurrentStreams returns a ServerOption that will apply a limit on the number // of concurrent streams to each ServerTransport.
[ "MaxConcurrentStreams", "returns", "a", "ServerOption", "that", "will", "apply", "a", "limit", "on", "the", "number", "of", "concurrent", "streams", "to", "each", "ServerTransport", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L287-L291
127,006
grpc/grpc-go
server.go
Creds
func Creds(c credentials.TransportCredentials) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.creds = c }) }
go
func Creds(c credentials.TransportCredentials) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.creds = c }) }
[ "func", "Creds", "(", "c", "credentials", ".", "TransportCredentials", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "creds", "=", "c", "\n", "}", ")", "\n", "}" ]
// Creds returns a ServerOption that sets credentials for server connections.
[ "Creds", "returns", "a", "ServerOption", "that", "sets", "credentials", "for", "server", "connections", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L294-L298
127,007
grpc/grpc-go
server.go
StreamInterceptor
func StreamInterceptor(i StreamServerInterceptor) ServerOption { return newFuncServerOption(func(o *serverOptions) { if o.streamInt != nil { panic("The stream server interceptor was already set and may not be reset.") } o.streamInt = i }) }
go
func StreamInterceptor(i StreamServerInterceptor) ServerOption { return newFuncServerOption(func(o *serverOptions) { if o.streamInt != nil { panic("The stream server interceptor was already set and may not be reset.") } o.streamInt = i }) }
[ "func", "StreamInterceptor", "(", "i", "StreamServerInterceptor", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "if", "o", ".", "streamInt", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", ...
// StreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the // server. Only one stream interceptor can be installed.
[ "StreamInterceptor", "returns", "a", "ServerOption", "that", "sets", "the", "StreamServerInterceptor", "for", "the", "server", ".", "Only", "one", "stream", "interceptor", "can", "be", "installed", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L314-L321
127,008
grpc/grpc-go
server.go
InTapHandle
func InTapHandle(h tap.ServerInHandle) ServerOption { return newFuncServerOption(func(o *serverOptions) { if o.inTapHandle != nil { panic("The tap handle was already set and may not be reset.") } o.inTapHandle = h }) }
go
func InTapHandle(h tap.ServerInHandle) ServerOption { return newFuncServerOption(func(o *serverOptions) { if o.inTapHandle != nil { panic("The tap handle was already set and may not be reset.") } o.inTapHandle = h }) }
[ "func", "InTapHandle", "(", "h", "tap", ".", "ServerInHandle", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "if", "o", ".", "inTapHandle", "!=", "nil", "{", "panic", "(", "\"", "\"", ")...
// InTapHandle returns a ServerOption that sets the tap handle for all the server // transport to be created. Only one can be installed.
[ "InTapHandle", "returns", "a", "ServerOption", "that", "sets", "the", "tap", "handle", "for", "all", "the", "server", "transport", "to", "be", "created", ".", "Only", "one", "can", "be", "installed", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L325-L332
127,009
grpc/grpc-go
server.go
StatsHandler
func StatsHandler(h stats.Handler) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.statsHandler = h }) }
go
func StatsHandler(h stats.Handler) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.statsHandler = h }) }
[ "func", "StatsHandler", "(", "h", "stats", ".", "Handler", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "statsHandler", "=", "h", "\n", "}", ")", "\n", "}" ]
// StatsHandler returns a ServerOption that sets the stats handler for the server.
[ "StatsHandler", "returns", "a", "ServerOption", "that", "sets", "the", "stats", "handler", "for", "the", "server", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L335-L339
127,010
grpc/grpc-go
server.go
UnknownServiceHandler
func UnknownServiceHandler(streamHandler StreamHandler) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.unknownStreamDesc = &StreamDesc{ StreamName: "unknown_service_handler", Handler: streamHandler, // We need to assume that the users of the streamHandler will want to use both. C...
go
func UnknownServiceHandler(streamHandler StreamHandler) ServerOption { return newFuncServerOption(func(o *serverOptions) { o.unknownStreamDesc = &StreamDesc{ StreamName: "unknown_service_handler", Handler: streamHandler, // We need to assume that the users of the streamHandler will want to use both. C...
[ "func", "UnknownServiceHandler", "(", "streamHandler", "StreamHandler", ")", "ServerOption", "{", "return", "newFuncServerOption", "(", "func", "(", "o", "*", "serverOptions", ")", "{", "o", ".", "unknownStreamDesc", "=", "&", "StreamDesc", "{", "StreamName", ":",...
// UnknownServiceHandler returns a ServerOption that allows for adding a custom // unknown service handler. The provided method is a bidi-streaming RPC service // handler that will be invoked instead of returning the "unimplemented" gRPC // error whenever a request is received for an unregistered service or method. // ...
[ "UnknownServiceHandler", "returns", "a", "ServerOption", "that", "allows", "for", "adding", "a", "custom", "unknown", "service", "handler", ".", "The", "provided", "method", "is", "a", "bidi", "-", "streaming", "RPC", "service", "handler", "that", "will", "be", ...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L347-L357
127,011
grpc/grpc-go
server.go
NewServer
func NewServer(opt ...ServerOption) *Server { opts := defaultServerOptions for _, o := range opt { o.apply(&opts) } s := &Server{ lis: make(map[net.Listener]bool), opts: opts, conns: make(map[io.Closer]bool), m: make(map[string]*service), quit: make(chan struct{}), done: make(chan struc...
go
func NewServer(opt ...ServerOption) *Server { opts := defaultServerOptions for _, o := range opt { o.apply(&opts) } s := &Server{ lis: make(map[net.Listener]bool), opts: opts, conns: make(map[io.Closer]bool), m: make(map[string]*service), quit: make(chan struct{}), done: make(chan struc...
[ "func", "NewServer", "(", "opt", "...", "ServerOption", ")", "*", "Server", "{", "opts", ":=", "defaultServerOptions", "\n", "for", "_", ",", "o", ":=", "range", "opt", "{", "o", ".", "apply", "(", "&", "opts", ")", "\n", "}", "\n", "s", ":=", "&",...
// NewServer creates a gRPC server which has no service registered and has not // started to accept requests yet.
[ "NewServer", "creates", "a", "gRPC", "server", "which", "has", "no", "service", "registered", "and", "has", "not", "started", "to", "accept", "requests", "yet", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L381-L405
127,012
grpc/grpc-go
server.go
printf
func (s *Server) printf(format string, a ...interface{}) { if s.events != nil { s.events.Printf(format, a...) } }
go
func (s *Server) printf(format string, a ...interface{}) { if s.events != nil { s.events.Printf(format, a...) } }
[ "func", "(", "s", "*", "Server", ")", "printf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "s", ".", "events", "!=", "nil", "{", "s", ".", "events", ".", "Printf", "(", "format", ",", "a", "...", ")", "\n",...
// printf records an event in s's event log, unless s has been stopped. // REQUIRES s.mu is held.
[ "printf", "records", "an", "event", "in", "s", "s", "event", "log", "unless", "s", "has", "been", "stopped", ".", "REQUIRES", "s", ".", "mu", "is", "held", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L409-L413
127,013
grpc/grpc-go
server.go
errorf
func (s *Server) errorf(format string, a ...interface{}) { if s.events != nil { s.events.Errorf(format, a...) } }
go
func (s *Server) errorf(format string, a ...interface{}) { if s.events != nil { s.events.Errorf(format, a...) } }
[ "func", "(", "s", "*", "Server", ")", "errorf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "s", ".", "events", "!=", "nil", "{", "s", ".", "events", ".", "Errorf", "(", "format", ",", "a", "...", ")", "\n",...
// errorf records an error in s's event log, unless s has been stopped. // REQUIRES s.mu is held.
[ "errorf", "records", "an", "error", "in", "s", "s", "event", "log", "unless", "s", "has", "been", "stopped", ".", "REQUIRES", "s", ".", "mu", "is", "held", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L417-L421
127,014
grpc/grpc-go
server.go
RegisterService
func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { ht := reflect.TypeOf(sd.HandlerType).Elem() st := reflect.TypeOf(ss) if !st.Implements(ht) { grpclog.Fatalf("grpc: Server.RegisterService found the handler of type %v that does not satisfy %v", st, ht) } s.register(sd, ss) }
go
func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { ht := reflect.TypeOf(sd.HandlerType).Elem() st := reflect.TypeOf(ss) if !st.Implements(ht) { grpclog.Fatalf("grpc: Server.RegisterService found the handler of type %v that does not satisfy %v", st, ht) } s.register(sd, ss) }
[ "func", "(", "s", "*", "Server", ")", "RegisterService", "(", "sd", "*", "ServiceDesc", ",", "ss", "interface", "{", "}", ")", "{", "ht", ":=", "reflect", ".", "TypeOf", "(", "sd", ".", "HandlerType", ")", ".", "Elem", "(", ")", "\n", "st", ":=", ...
// RegisterService registers a service and its implementation to the gRPC // server. It is called from the IDL generated code. This must be called before // invoking Serve.
[ "RegisterService", "registers", "a", "service", "and", "its", "implementation", "to", "the", "gRPC", "server", ".", "It", "is", "called", "from", "the", "IDL", "generated", "code", ".", "This", "must", "be", "called", "before", "invoking", "Serve", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L426-L433
127,015
grpc/grpc-go
server.go
Serve
func (s *Server) Serve(lis net.Listener) error { s.mu.Lock() s.printf("serving") s.serve = true if s.lis == nil { // Serve called after Stop or GracefulStop. s.mu.Unlock() lis.Close() return ErrServerStopped } s.serveWG.Add(1) defer func() { s.serveWG.Done() select { // Stop or GracefulStop called...
go
func (s *Server) Serve(lis net.Listener) error { s.mu.Lock() s.printf("serving") s.serve = true if s.lis == nil { // Serve called after Stop or GracefulStop. s.mu.Unlock() lis.Close() return ErrServerStopped } s.serveWG.Add(1) defer func() { s.serveWG.Done() select { // Stop or GracefulStop called...
[ "func", "(", "s", "*", "Server", ")", "Serve", "(", "lis", "net", ".", "Listener", ")", "error", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "s", ".", "printf", "(", "\"", "\"", ")", "\n", "s", ".", "serve", "=", "true", "\n", "if", "...
// Serve accepts incoming connections on the listener lis, creating a new // ServerTransport and service goroutine for each. The service goroutines // read gRPC requests and then call the registered handlers to reply to them. // Serve returns when lis.Accept fails with fatal errors. lis will be closed when // this met...
[ "Serve", "accepts", "incoming", "connections", "on", "the", "listener", "lis", "creating", "a", "new", "ServerTransport", "and", "service", "goroutine", "for", "each", ".", "The", "service", "goroutines", "read", "gRPC", "requests", "and", "then", "call", "the",...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L545-L635
127,016
grpc/grpc-go
server.go
traceInfo
func (s *Server) traceInfo(st transport.ServerTransport, stream *transport.Stream) (trInfo *traceInfo) { tr, ok := trace.FromContext(stream.Context()) if !ok { return nil } trInfo = &traceInfo{ tr: tr, firstLine: firstLine{ client: false, remoteAddr: st.RemoteAddr(), }, } if dl, ok := stream.Co...
go
func (s *Server) traceInfo(st transport.ServerTransport, stream *transport.Stream) (trInfo *traceInfo) { tr, ok := trace.FromContext(stream.Context()) if !ok { return nil } trInfo = &traceInfo{ tr: tr, firstLine: firstLine{ client: false, remoteAddr: st.RemoteAddr(), }, } if dl, ok := stream.Co...
[ "func", "(", "s", "*", "Server", ")", "traceInfo", "(", "st", "transport", ".", "ServerTransport", ",", "stream", "*", "transport", ".", "Stream", ")", "(", "trInfo", "*", "traceInfo", ")", "{", "tr", ",", "ok", ":=", "trace", ".", "FromContext", "(", ...
// traceInfo returns a traceInfo and associates it with stream, if tracing is enabled. // If tracing is not enabled, it returns nil.
[ "traceInfo", "returns", "a", "traceInfo", "and", "associates", "it", "with", "stream", "if", "tracing", "is", "enabled", ".", "If", "tracing", "is", "not", "enabled", "it", "returns", "nil", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L770-L787
127,017
grpc/grpc-go
server.go
NewContextWithServerTransportStream
func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context { return context.WithValue(ctx, streamKey{}, stream) }
go
func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context { return context.WithValue(ctx, streamKey{}, stream) }
[ "func", "NewContextWithServerTransportStream", "(", "ctx", "context", ".", "Context", ",", "stream", "ServerTransportStream", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "streamKey", "{", "}", ",", "stream", ")", ...
// NewContextWithServerTransportStream creates a new context from ctx and // attaches stream to it. // // This API is EXPERIMENTAL.
[ "NewContextWithServerTransportStream", "creates", "a", "new", "context", "from", "ctx", "and", "attaches", "stream", "to", "it", ".", "This", "API", "is", "EXPERIMENTAL", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L1320-L1322
127,018
grpc/grpc-go
server.go
GracefulStop
func (s *Server) GracefulStop() { s.quitOnce.Do(func() { close(s.quit) }) defer func() { s.doneOnce.Do(func() { close(s.done) }) }() s.channelzRemoveOnce.Do(func() { if channelz.IsOn() { channelz.RemoveEntry(s.channelzID) } }) s.mu.Lock() if s.conns == nil { s.mu.Unlock() return } for l...
go
func (s *Server) GracefulStop() { s.quitOnce.Do(func() { close(s.quit) }) defer func() { s.doneOnce.Do(func() { close(s.done) }) }() s.channelzRemoveOnce.Do(func() { if channelz.IsOn() { channelz.RemoveEntry(s.channelzID) } }) s.mu.Lock() if s.conns == nil { s.mu.Unlock() return } for l...
[ "func", "(", "s", "*", "Server", ")", "GracefulStop", "(", ")", "{", "s", ".", "quitOnce", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "s", ".", "quit", ")", "\n", "}", ")", "\n\n", "defer", "func", "(", ")", "{", "s", ".", "doneOnce...
// GracefulStop stops the gRPC server gracefully. It stops the server from // accepting new connections and RPCs and blocks until all the pending RPCs are // finished.
[ "GracefulStop", "stops", "the", "gRPC", "server", "gracefully", ".", "It", "stops", "the", "server", "from", "accepting", "new", "connections", "and", "RPCs", "and", "blocks", "until", "all", "the", "pending", "RPCs", "are", "finished", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L1399-L1447
127,019
grpc/grpc-go
server.go
getCodec
func (s *Server) getCodec(contentSubtype string) baseCodec { if s.opts.codec != nil { return s.opts.codec } if contentSubtype == "" { return encoding.GetCodec(proto.Name) } codec := encoding.GetCodec(contentSubtype) if codec == nil { return encoding.GetCodec(proto.Name) } return codec }
go
func (s *Server) getCodec(contentSubtype string) baseCodec { if s.opts.codec != nil { return s.opts.codec } if contentSubtype == "" { return encoding.GetCodec(proto.Name) } codec := encoding.GetCodec(contentSubtype) if codec == nil { return encoding.GetCodec(proto.Name) } return codec }
[ "func", "(", "s", "*", "Server", ")", "getCodec", "(", "contentSubtype", "string", ")", "baseCodec", "{", "if", "s", ".", "opts", ".", "codec", "!=", "nil", "{", "return", "s", ".", "opts", ".", "codec", "\n", "}", "\n", "if", "contentSubtype", "==",...
// contentSubtype must be lowercase // cannot return nil
[ "contentSubtype", "must", "be", "lowercase", "cannot", "return", "nil" ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/server.go#L1451-L1463
127,020
grpc/grpc-go
internal/transport/http_util.go
isReservedHeader
func isReservedHeader(hdr string) bool { if hdr != "" && hdr[0] == ':' { return true } switch hdr { case "content-type", "user-agent", "grpc-message-type", "grpc-encoding", "grpc-message", "grpc-status", "grpc-timeout", "grpc-status-details-bin", // Intentionally exclude grpc-previous-rpc-attempts...
go
func isReservedHeader(hdr string) bool { if hdr != "" && hdr[0] == ':' { return true } switch hdr { case "content-type", "user-agent", "grpc-message-type", "grpc-encoding", "grpc-message", "grpc-status", "grpc-timeout", "grpc-status-details-bin", // Intentionally exclude grpc-previous-rpc-attempts...
[ "func", "isReservedHeader", "(", "hdr", "string", ")", "bool", "{", "if", "hdr", "!=", "\"", "\"", "&&", "hdr", "[", "0", "]", "==", "':'", "{", "return", "true", "\n", "}", "\n", "switch", "hdr", "{", "case", "\"", "\"", ",", "\"", "\"", ",", ...
// isReservedHeader checks whether hdr belongs to HTTP2 headers // reserved by gRPC protocol. Any other headers are classified as the // user-specified metadata.
[ "isReservedHeader", "checks", "whether", "hdr", "belongs", "to", "HTTP2", "headers", "reserved", "by", "gRPC", "protocol", ".", "Any", "other", "headers", "are", "classified", "as", "the", "user", "-", "specified", "metadata", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http_util.go#L151-L172
127,021
grpc/grpc-go
internal/transport/http_util.go
encodeGrpcMessage
func encodeGrpcMessage(msg string) string { if msg == "" { return "" } lenMsg := len(msg) for i := 0; i < lenMsg; i++ { c := msg[i] if !(c >= spaceByte && c <= tildeByte && c != percentByte) { return encodeGrpcMessageUnchecked(msg) } } return msg }
go
func encodeGrpcMessage(msg string) string { if msg == "" { return "" } lenMsg := len(msg) for i := 0; i < lenMsg; i++ { c := msg[i] if !(c >= spaceByte && c <= tildeByte && c != percentByte) { return encodeGrpcMessageUnchecked(msg) } } return msg }
[ "func", "encodeGrpcMessage", "(", "msg", "string", ")", "string", "{", "if", "msg", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "lenMsg", ":=", "len", "(", "msg", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "lenMsg", ";", ...
// encodeGrpcMessage is used to encode status code in header field // "grpc-message". It does percent encoding and also replaces invalid utf-8 // characters with Unicode replacement character. // // It checks to see if each individual byte in msg is an allowable byte, and // then either percent encoding or passing it t...
[ "encodeGrpcMessage", "is", "used", "to", "encode", "status", "code", "in", "header", "field", "grpc", "-", "message", ".", "It", "does", "percent", "encoding", "and", "also", "replaces", "invalid", "utf", "-", "8", "characters", "with", "Unicode", "replacement...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http_util.go#L526-L538
127,022
grpc/grpc-go
internal/transport/http_util.go
decodeGrpcMessage
func decodeGrpcMessage(msg string) string { if msg == "" { return "" } lenMsg := len(msg) for i := 0; i < lenMsg; i++ { if msg[i] == percentByte && i+2 < lenMsg { return decodeGrpcMessageUnchecked(msg) } } return msg }
go
func decodeGrpcMessage(msg string) string { if msg == "" { return "" } lenMsg := len(msg) for i := 0; i < lenMsg; i++ { if msg[i] == percentByte && i+2 < lenMsg { return decodeGrpcMessageUnchecked(msg) } } return msg }
[ "func", "decodeGrpcMessage", "(", "msg", "string", ")", "string", "{", "if", "msg", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "lenMsg", ":=", "len", "(", "msg", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "lenMsg", ";", ...
// decodeGrpcMessage decodes the msg encoded by encodeGrpcMessage.
[ "decodeGrpcMessage", "decodes", "the", "msg", "encoded", "by", "encodeGrpcMessage", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http_util.go#L567-L578
127,023
grpc/grpc-go
credentials/alts/internal/conn/utils.go
CounterFromValue
func CounterFromValue(value []byte, overflowLen int) (c Counter) { c.overflowLen = overflowLen copy(c.value[:], value) return }
go
func CounterFromValue(value []byte, overflowLen int) (c Counter) { c.overflowLen = overflowLen copy(c.value[:], value) return }
[ "func", "CounterFromValue", "(", "value", "[", "]", "byte", ",", "overflowLen", "int", ")", "(", "c", "Counter", ")", "{", "c", ".", "overflowLen", "=", "overflowLen", "\n", "copy", "(", "c", ".", "value", "[", ":", "]", ",", "value", ")", "\n", "r...
// CounterFromValue creates a new counter given an initial value.
[ "CounterFromValue", "creates", "a", "new", "counter", "given", "an", "initial", "value", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/utils.go#L50-L54
127,024
grpc/grpc-go
credentials/alts/alts.go
NewClientCreds
func NewClientCreds(opts *ClientOptions) credentials.TransportCredentials { return newALTS(core.ClientSide, opts.TargetServiceAccounts, opts.HandshakerServiceAddress) }
go
func NewClientCreds(opts *ClientOptions) credentials.TransportCredentials { return newALTS(core.ClientSide, opts.TargetServiceAccounts, opts.HandshakerServiceAddress) }
[ "func", "NewClientCreds", "(", "opts", "*", "ClientOptions", ")", "credentials", ".", "TransportCredentials", "{", "return", "newALTS", "(", "core", ".", "ClientSide", ",", "opts", ".", "TargetServiceAccounts", ",", "opts", ".", "HandshakerServiceAddress", ")", "\...
// NewClientCreds constructs a client-side ALTS TransportCredentials object.
[ "NewClientCreds", "constructs", "a", "client", "-", "side", "ALTS", "TransportCredentials", "object", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/alts.go#L140-L142
127,025
grpc/grpc-go
credentials/alts/alts.go
NewServerCreds
func NewServerCreds(opts *ServerOptions) credentials.TransportCredentials { return newALTS(core.ServerSide, nil, opts.HandshakerServiceAddress) }
go
func NewServerCreds(opts *ServerOptions) credentials.TransportCredentials { return newALTS(core.ServerSide, nil, opts.HandshakerServiceAddress) }
[ "func", "NewServerCreds", "(", "opts", "*", "ServerOptions", ")", "credentials", ".", "TransportCredentials", "{", "return", "newALTS", "(", "core", ".", "ServerSide", ",", "nil", ",", "opts", ".", "HandshakerServiceAddress", ")", "\n", "}" ]
// NewServerCreds constructs a server-side ALTS TransportCredentials object.
[ "NewServerCreds", "constructs", "a", "server", "-", "side", "ALTS", "TransportCredentials", "object", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/alts.go#L145-L147
127,026
grpc/grpc-go
credentials/alts/alts.go
ClientHandshake
func (g *altsTC) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { if !vmOnGCP { return nil, nil, ErrUntrustedPlatform } // Connecting to ALTS handshaker service. hsConn, err := service.Dial(g.hsAddress) if err != nil { return nil, nil, err ...
go
func (g *altsTC) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { if !vmOnGCP { return nil, nil, ErrUntrustedPlatform } // Connecting to ALTS handshaker service. hsConn, err := service.Dial(g.hsAddress) if err != nil { return nil, nil, err ...
[ "func", "(", "g", "*", "altsTC", ")", "ClientHandshake", "(", "ctx", "context", ".", "Context", ",", "addr", "string", ",", "rawConn", "net", ".", "Conn", ")", "(", "_", "net", ".", "Conn", ",", "_", "credentials", ".", "AuthInfo", ",", "err", "error...
// ClientHandshake implements the client side handshake protocol.
[ "ClientHandshake", "implements", "the", "client", "side", "handshake", "protocol", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/alts.go#L169-L221
127,027
grpc/grpc-go
credentials/alts/alts.go
ServerHandshake
func (g *altsTC) ServerHandshake(rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { if !vmOnGCP { return nil, nil, ErrUntrustedPlatform } // Connecting to ALTS handshaker service. hsConn, err := service.Dial(g.hsAddress) if err != nil { return nil, nil, err } // Do not close hsConn since it'...
go
func (g *altsTC) ServerHandshake(rawConn net.Conn) (_ net.Conn, _ credentials.AuthInfo, err error) { if !vmOnGCP { return nil, nil, ErrUntrustedPlatform } // Connecting to ALTS handshaker service. hsConn, err := service.Dial(g.hsAddress) if err != nil { return nil, nil, err } // Do not close hsConn since it'...
[ "func", "(", "g", "*", "altsTC", ")", "ServerHandshake", "(", "rawConn", "net", ".", "Conn", ")", "(", "_", "net", ".", "Conn", ",", "_", "credentials", ".", "AuthInfo", ",", "err", "error", ")", "{", "if", "!", "vmOnGCP", "{", "return", "nil", ","...
// ServerHandshake implements the server side ALTS handshaker.
[ "ServerHandshake", "implements", "the", "server", "side", "ALTS", "handshaker", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/alts.go#L224-L264
127,028
grpc/grpc-go
credentials/alts/alts.go
checkRPCVersions
func checkRPCVersions(local, peer *altspb.RpcProtocolVersions) (bool, *altspb.RpcProtocolVersions_Version) { if local == nil || peer == nil { grpclog.Error("invalid checkRPCVersions argument, either local or peer is nil.") return false, nil } // maxCommonVersion is MIN(local.max, peer.max). maxCommonVersion :=...
go
func checkRPCVersions(local, peer *altspb.RpcProtocolVersions) (bool, *altspb.RpcProtocolVersions_Version) { if local == nil || peer == nil { grpclog.Error("invalid checkRPCVersions argument, either local or peer is nil.") return false, nil } // maxCommonVersion is MIN(local.max, peer.max). maxCommonVersion :=...
[ "func", "checkRPCVersions", "(", "local", ",", "peer", "*", "altspb", ".", "RpcProtocolVersions", ")", "(", "bool", ",", "*", "altspb", ".", "RpcProtocolVersions_Version", ")", "{", "if", "local", "==", "nil", "||", "peer", "==", "nil", "{", "grpclog", "."...
// checkRPCVersions performs a version check between local and peer rpc protocol // versions. This function returns true if the check passes which means both // parties agreed on a common rpc protocol to use, and false otherwise. The // function also returns the highest common RPC protocol version both parties // agree...
[ "checkRPCVersions", "performs", "a", "version", "check", "between", "local", "and", "peer", "rpc", "protocol", "versions", ".", "This", "function", "returns", "true", "if", "the", "check", "passes", "which", "means", "both", "parties", "agreed", "on", "a", "co...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/alts.go#L308-L330
127,029
grpc/grpc-go
resolver/dns/dns_resolver.go
Build
func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) { host, port, err := parseTarget(target.Endpoint, defaultPort) if err != nil { return nil, err } // IP address. if net.ParseIP(host) != nil { host, _ = formatIP(host) addr := []re...
go
func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOption) (resolver.Resolver, error) { host, port, err := parseTarget(target.Endpoint, defaultPort) if err != nil { return nil, err } // IP address. if net.ParseIP(host) != nil { host, _ = formatIP(host) addr := []re...
[ "func", "(", "b", "*", "dnsBuilder", ")", "Build", "(", "target", "resolver", ".", "Target", ",", "cc", "resolver", ".", "ClientConn", ",", "opts", "resolver", ".", "BuildOption", ")", "(", "resolver", ".", "Resolver", ",", "error", ")", "{", "host", "...
// Build creates and starts a DNS resolver that watches the name resolution of the target.
[ "Build", "creates", "and", "starts", "a", "DNS", "resolver", "that", "watches", "the", "name", "resolution", "of", "the", "target", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/resolver/dns/dns_resolver.go#L106-L154
127,030
grpc/grpc-go
resolver/dns/dns_resolver.go
Close
func (d *dnsResolver) Close() { d.cancel() d.wg.Wait() d.t.Stop() }
go
func (d *dnsResolver) Close() { d.cancel() d.wg.Wait() d.t.Stop() }
[ "func", "(", "d", "*", "dnsResolver", ")", "Close", "(", ")", "{", "d", ".", "cancel", "(", ")", "\n", "d", ".", "wg", ".", "Wait", "(", ")", "\n", "d", ".", "t", ".", "Stop", "(", ")", "\n", "}" ]
// Close closes the dnsResolver.
[ "Close", "closes", "the", "dnsResolver", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/resolver/dns/dns_resolver.go#L233-L237
127,031
grpc/grpc-go
resolver/dns/dns_resolver.go
formatIP
func formatIP(addr string) (addrIP string, ok bool) { ip := net.ParseIP(addr) if ip == nil { return "", false } if ip.To4() != nil { return addr, true } return "[" + addr + "]", true }
go
func formatIP(addr string) (addrIP string, ok bool) { ip := net.ParseIP(addr) if ip == nil { return "", false } if ip.To4() != nil { return addr, true } return "[" + addr + "]", true }
[ "func", "formatIP", "(", "addr", "string", ")", "(", "addrIP", "string", ",", "ok", "bool", ")", "{", "ip", ":=", "net", ".", "ParseIP", "(", "addr", ")", "\n", "if", "ip", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", ...
// formatIP returns ok = false if addr is not a valid textual representation of an IP address. // If addr is an IPv4 address, return the addr and ok = true. // If addr is an IPv6 address, return the addr enclosed in square brackets and ok = true.
[ "formatIP", "returns", "ok", "=", "false", "if", "addr", "is", "not", "a", "valid", "textual", "representation", "of", "an", "IP", "address", ".", "If", "addr", "is", "an", "IPv4", "address", "return", "the", "addr", "and", "ok", "=", "true", ".", "If"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/resolver/dns/dns_resolver.go#L357-L366
127,032
grpc/grpc-go
health/server.go
Check
func (s *Server) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) { s.mu.Lock() defer s.mu.Unlock() if servingStatus, ok := s.statusMap[in.Service]; ok { return &healthpb.HealthCheckResponse{ Status: servingStatus, }, nil } return nil, status.Error(codes.Not...
go
func (s *Server) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) { s.mu.Lock() defer s.mu.Unlock() if servingStatus, ok := s.statusMap[in.Service]; ok { return &healthpb.HealthCheckResponse{ Status: servingStatus, }, nil } return nil, status.Error(codes.Not...
[ "func", "(", "s", "*", "Server", ")", "Check", "(", "ctx", "context", ".", "Context", ",", "in", "*", "healthpb", ".", "HealthCheckRequest", ")", "(", "*", "healthpb", ".", "HealthCheckResponse", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "...
// Check implements `service Health`.
[ "Check", "implements", "service", "Health", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/health/server.go#L56-L65
127,033
grpc/grpc-go
health/server.go
Watch
func (s *Server) Watch(in *healthpb.HealthCheckRequest, stream healthgrpc.Health_WatchServer) error { service := in.Service // update channel is used for getting service status updates. update := make(chan healthpb.HealthCheckResponse_ServingStatus, 1) s.mu.Lock() // Puts the initial status to the channel. if ser...
go
func (s *Server) Watch(in *healthpb.HealthCheckRequest, stream healthgrpc.Health_WatchServer) error { service := in.Service // update channel is used for getting service status updates. update := make(chan healthpb.HealthCheckResponse_ServingStatus, 1) s.mu.Lock() // Puts the initial status to the channel. if ser...
[ "func", "(", "s", "*", "Server", ")", "Watch", "(", "in", "*", "healthpb", ".", "HealthCheckRequest", ",", "stream", "healthgrpc", ".", "Health_WatchServer", ")", "error", "{", "service", ":=", "in", ".", "Service", "\n", "// update channel is used for getting s...
// Watch implements `service Health`.
[ "Watch", "implements", "service", "Health", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/health/server.go#L68-L110
127,034
grpc/grpc-go
examples/features/interceptor/client/main.go
unaryInterceptor
func unaryInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { var credsConfigured bool for _, o := range opts { _, ok := o.(grpc.PerRPCCredsCallOption) if ok { credsConfigured = true break } } if !credsC...
go
func unaryInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { var credsConfigured bool for _, o := range opts { _, ok := o.(grpc.PerRPCCredsCallOption) if ok { credsConfigured = true break } } if !credsC...
[ "func", "unaryInterceptor", "(", "ctx", "context", ".", "Context", ",", "method", "string", ",", "req", ",", "reply", "interface", "{", "}", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "invoker", "grpc", ".", "UnaryInvoker", ",", "opts", "...", "grpc...
// unaryInterceptor is an example unary interceptor.
[ "unaryInterceptor", "is", "an", "example", "unary", "interceptor", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/interceptor/client/main.go#L48-L67
127,035
grpc/grpc-go
examples/features/interceptor/client/main.go
streamInterceptor
func streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { var credsConfigured bool for _, o := range opts { _, ok := o.(*grpc.PerRPCCredsCallOption) if ok { credsConfigured = true } } ...
go
func streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { var credsConfigured bool for _, o := range opts { _, ok := o.(*grpc.PerRPCCredsCallOption) if ok { credsConfigured = true } } ...
[ "func", "streamInterceptor", "(", "ctx", "context", ".", "Context", ",", "desc", "*", "grpc", ".", "StreamDesc", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "method", "string", ",", "streamer", "grpc", ".", "Streamer", ",", "opts", "...", "grpc", "."...
// streamInterceptor is an example stream interceptor.
[ "streamInterceptor", "is", "an", "example", "stream", "interceptor", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/interceptor/client/main.go#L90-L108
127,036
grpc/grpc-go
internal/grpcrand/grpcrand.go
Int63n
func Int63n(n int64) int64 { mu.Lock() res := r.Int63n(n) mu.Unlock() return res }
go
func Int63n(n int64) int64 { mu.Lock() res := r.Int63n(n) mu.Unlock() return res }
[ "func", "Int63n", "(", "n", "int64", ")", "int64", "{", "mu", ".", "Lock", "(", ")", "\n", "res", ":=", "r", ".", "Int63n", "(", "n", ")", "\n", "mu", ".", "Unlock", "(", ")", "\n", "return", "res", "\n", "}" ]
// Int63n implements rand.Int63n on the grpcrand global source.
[ "Int63n", "implements", "rand", ".", "Int63n", "on", "the", "grpcrand", "global", "source", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/grpcrand/grpcrand.go#L35-L40
127,037
grpc/grpc-go
internal/grpcrand/grpcrand.go
Intn
func Intn(n int) int { mu.Lock() res := r.Intn(n) mu.Unlock() return res }
go
func Intn(n int) int { mu.Lock() res := r.Intn(n) mu.Unlock() return res }
[ "func", "Intn", "(", "n", "int", ")", "int", "{", "mu", ".", "Lock", "(", ")", "\n", "res", ":=", "r", ".", "Intn", "(", "n", ")", "\n", "mu", ".", "Unlock", "(", ")", "\n", "return", "res", "\n", "}" ]
// Intn implements rand.Intn on the grpcrand global source.
[ "Intn", "implements", "rand", ".", "Intn", "on", "the", "grpcrand", "global", "source", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/grpcrand/grpcrand.go#L43-L48
127,038
grpc/grpc-go
internal/grpcrand/grpcrand.go
Float64
func Float64() float64 { mu.Lock() res := r.Float64() mu.Unlock() return res }
go
func Float64() float64 { mu.Lock() res := r.Float64() mu.Unlock() return res }
[ "func", "Float64", "(", ")", "float64", "{", "mu", ".", "Lock", "(", ")", "\n", "res", ":=", "r", ".", "Float64", "(", ")", "\n", "mu", ".", "Unlock", "(", ")", "\n", "return", "res", "\n", "}" ]
// Float64 implements rand.Float64 on the grpcrand global source.
[ "Float64", "implements", "rand", ".", "Float64", "on", "the", "grpcrand", "global", "source", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/grpcrand/grpcrand.go#L51-L56
127,039
grpc/grpc-go
credentials/alts/internal/handshaker/handshaker.go
NewClientHandshaker
func NewClientHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ClientHandshakerOptions) (core.Handshaker, error) { stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) if err != nil { return nil, err } return &altsHandshaker{ stream: stre...
go
func NewClientHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ClientHandshakerOptions) (core.Handshaker, error) { stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) if err != nil { return nil, err } return &altsHandshaker{ stream: stre...
[ "func", "NewClientHandshaker", "(", "ctx", "context", ".", "Context", ",", "conn", "*", "grpc", ".", "ClientConn", ",", "c", "net", ".", "Conn", ",", "opts", "*", "ClientHandshakerOptions", ")", "(", "core", ".", "Handshaker", ",", "error", ")", "{", "st...
// NewClientHandshaker creates a ALTS handshaker for GCP which contains an RPC // stub created using the passed conn and used to talk to the ALTS Handshaker // service in the metadata server.
[ "NewClientHandshaker", "creates", "a", "ALTS", "handshaker", "for", "GCP", "which", "contains", "an", "RPC", "stub", "created", "using", "the", "passed", "conn", "and", "used", "to", "talk", "to", "the", "ALTS", "Handshaker", "service", "in", "the", "metadata"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/handshaker.go#L153-L164
127,040
grpc/grpc-go
credentials/alts/internal/handshaker/handshaker.go
NewServerHandshaker
func NewServerHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ServerHandshakerOptions) (core.Handshaker, error) { stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) if err != nil { return nil, err } return &altsHandshaker{ stream: stre...
go
func NewServerHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ServerHandshakerOptions) (core.Handshaker, error) { stream, err := altsgrpc.NewHandshakerServiceClient(conn).DoHandshake(ctx, grpc.WaitForReady(true)) if err != nil { return nil, err } return &altsHandshaker{ stream: stre...
[ "func", "NewServerHandshaker", "(", "ctx", "context", ".", "Context", ",", "conn", "*", "grpc", ".", "ClientConn", ",", "c", "net", ".", "Conn", ",", "opts", "*", "ServerHandshakerOptions", ")", "(", "core", ".", "Handshaker", ",", "error", ")", "{", "st...
// NewServerHandshaker creates a ALTS handshaker for GCP which contains an RPC // stub created using the passed conn and used to talk to the ALTS Handshaker // service in the metadata server.
[ "NewServerHandshaker", "creates", "a", "ALTS", "handshaker", "for", "GCP", "which", "contains", "an", "RPC", "stub", "created", "using", "the", "passed", "conn", "and", "used", "to", "talk", "to", "the", "ALTS", "Handshaker", "service", "in", "the", "metadata"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/handshaker.go#L169-L180
127,041
grpc/grpc-go
credentials/alts/internal/handshaker/handshaker.go
ClientHandshake
func (h *altsHandshaker) ClientHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { if !acquire(1) { return nil, nil, errDropped } defer release(1) if h.side != core.ClientSide { return nil, nil, errors.New("only handshakers created using NewClientHandshaker can perform a client handshaker"...
go
func (h *altsHandshaker) ClientHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { if !acquire(1) { return nil, nil, errDropped } defer release(1) if h.side != core.ClientSide { return nil, nil, errors.New("only handshakers created using NewClientHandshaker can perform a client handshaker"...
[ "func", "(", "h", "*", "altsHandshaker", ")", "ClientHandshake", "(", "ctx", "context", ".", "Context", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "if", "!", "acquire", "(", "1", ")", "{", "return", "ni...
// ClientHandshake starts and completes a client ALTS handshaking for GCP. Once // done, ClientHandshake returns a secure connection.
[ "ClientHandshake", "starts", "and", "completes", "a", "client", "ALTS", "handshaking", "for", "GCP", ".", "Once", "done", "ClientHandshake", "returns", "a", "secure", "connection", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/handshaker.go#L184-L223
127,042
grpc/grpc-go
credentials/alts/internal/handshaker/handshaker.go
ServerHandshake
func (h *altsHandshaker) ServerHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { if !acquire(1) { return nil, nil, errDropped } defer release(1) if h.side != core.ServerSide { return nil, nil, errors.New("only handshakers created using NewServerHandshaker can perform a server handshaker"...
go
func (h *altsHandshaker) ServerHandshake(ctx context.Context) (net.Conn, credentials.AuthInfo, error) { if !acquire(1) { return nil, nil, errDropped } defer release(1) if h.side != core.ServerSide { return nil, nil, errors.New("only handshakers created using NewServerHandshaker can perform a server handshaker"...
[ "func", "(", "h", "*", "altsHandshaker", ")", "ServerHandshake", "(", "ctx", "context", ".", "Context", ")", "(", "net", ".", "Conn", ",", "credentials", ".", "AuthInfo", ",", "error", ")", "{", "if", "!", "acquire", "(", "1", ")", "{", "return", "ni...
// ServerHandshake starts and completes a server ALTS handshaking for GCP. Once // done, ServerHandshake returns a secure connection.
[ "ServerHandshake", "starts", "and", "completes", "a", "server", "ALTS", "handshaking", "for", "GCP", ".", "Once", "done", "ServerHandshake", "returns", "a", "secure", "connection", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/handshaker.go#L227-L267
127,043
grpc/grpc-go
credentials/alts/internal/handshaker/handshaker.go
processUntilDone
func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []byte) (*altspb.HandshakerResult, []byte, error) { for { if len(resp.OutFrames) > 0 { if _, err := h.conn.Write(resp.OutFrames); err != nil { return nil, nil, err } } if resp.Result != nil { return resp.Result, extra, nil ...
go
func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []byte) (*altspb.HandshakerResult, []byte, error) { for { if len(resp.OutFrames) > 0 { if _, err := h.conn.Write(resp.OutFrames); err != nil { return nil, nil, err } } if resp.Result != nil { return resp.Result, extra, nil ...
[ "func", "(", "h", "*", "altsHandshaker", ")", "processUntilDone", "(", "resp", "*", "altspb", ".", "HandshakerResp", ",", "extra", "[", "]", "byte", ")", "(", "*", "altspb", ".", "HandshakerResult", ",", "[", "]", "byte", ",", "error", ")", "{", "for",...
// processUntilDone processes the handshake until the handshaker service returns // the results. Handshaker service takes care of frame parsing, so we read // whatever received from the network and send it to the handshaker service.
[ "processUntilDone", "processes", "the", "handshake", "until", "the", "handshaker", "service", "returns", "the", "results", ".", "Handshaker", "service", "takes", "care", "of", "frame", "parsing", "so", "we", "read", "whatever", "received", "from", "the", "network"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/handshaker/handshaker.go#L316-L359
127,044
grpc/grpc-go
internal/transport/http2_client.go
CloseStream
func (t *http2Client) CloseStream(s *Stream, err error) { var ( rst bool rstCode http2.ErrCode ) if err != nil { rst = true rstCode = http2.ErrCodeCancel } t.closeStream(s, err, rst, rstCode, status.Convert(err), nil, false) }
go
func (t *http2Client) CloseStream(s *Stream, err error) { var ( rst bool rstCode http2.ErrCode ) if err != nil { rst = true rstCode = http2.ErrCodeCancel } t.closeStream(s, err, rst, rstCode, status.Convert(err), nil, false) }
[ "func", "(", "t", "*", "http2Client", ")", "CloseStream", "(", "s", "*", "Stream", ",", "err", "error", ")", "{", "var", "(", "rst", "bool", "\n", "rstCode", "http2", ".", "ErrCode", "\n", ")", "\n", "if", "err", "!=", "nil", "{", "rst", "=", "tr...
// CloseStream clears the footprint of a stream when the stream is not needed any more. // This must not be executed in reader's goroutine.
[ "CloseStream", "clears", "the", "footprint", "of", "a", "stream", "when", "the", "stream", "is", "not", "needed", "any", "more", ".", "This", "must", "not", "be", "executed", "in", "reader", "s", "goroutine", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L684-L694
127,045
grpc/grpc-go
internal/transport/http2_client.go
GracefulClose
func (t *http2Client) GracefulClose() { t.mu.Lock() // Make sure we move to draining only from active. if t.state == draining || t.state == closing { t.mu.Unlock() return } t.state = draining active := len(t.activeStreams) t.mu.Unlock() if active == 0 { t.Close() return } t.controlBuf.put(&incomingGoA...
go
func (t *http2Client) GracefulClose() { t.mu.Lock() // Make sure we move to draining only from active. if t.state == draining || t.state == closing { t.mu.Unlock() return } t.state = draining active := len(t.activeStreams) t.mu.Unlock() if active == 0 { t.Close() return } t.controlBuf.put(&incomingGoA...
[ "func", "(", "t", "*", "http2Client", ")", "GracefulClose", "(", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "// Make sure we move to draining only from active.", "if", "t", ".", "state", "==", "draining", "||", "t", ".", "state", "==", "closing...
// GracefulClose sets the state to draining, which prevents new streams from // being created and causes the transport to be closed when the last active // stream is closed. If there are no active streams, the transport is closed // immediately. This does nothing if the transport is already draining or // closing.
[ "GracefulClose", "sets", "the", "state", "to", "draining", "which", "prevents", "new", "streams", "from", "being", "created", "and", "causes", "the", "transport", "to", "be", "closed", "when", "the", "last", "active", "stream", "is", "closed", ".", "If", "th...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L797-L812
127,046
grpc/grpc-go
internal/transport/http2_client.go
updateWindow
func (t *http2Client) updateWindow(s *Stream, n uint32) { if w := s.fc.onRead(n); w > 0 { t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) } }
go
func (t *http2Client) updateWindow(s *Stream, n uint32) { if w := s.fc.onRead(n); w > 0 { t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) } }
[ "func", "(", "t", "*", "http2Client", ")", "updateWindow", "(", "s", "*", "Stream", ",", "n", "uint32", ")", "{", "if", "w", ":=", "s", ".", "fc", ".", "onRead", "(", "n", ")", ";", "w", ">", "0", "{", "t", ".", "controlBuf", ".", "put", "(",...
// updateWindow adjusts the inbound quota for the stream. // Window updates will be sent out when the cumulative quota // exceeds the corresponding threshold.
[ "updateWindow", "adjusts", "the", "inbound", "quota", "for", "the", "stream", ".", "Window", "updates", "will", "be", "sent", "out", "when", "the", "cumulative", "quota", "exceeds", "the", "corresponding", "threshold", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L866-L870
127,047
grpc/grpc-go
internal/transport/http2_client.go
setGoAwayReason
func (t *http2Client) setGoAwayReason(f *http2.GoAwayFrame) { t.goAwayReason = GoAwayNoReason switch f.ErrCode { case http2.ErrCodeEnhanceYourCalm: if string(f.DebugData()) == "too_many_pings" { t.goAwayReason = GoAwayTooManyPings } } }
go
func (t *http2Client) setGoAwayReason(f *http2.GoAwayFrame) { t.goAwayReason = GoAwayNoReason switch f.ErrCode { case http2.ErrCodeEnhanceYourCalm: if string(f.DebugData()) == "too_many_pings" { t.goAwayReason = GoAwayTooManyPings } } }
[ "func", "(", "t", "*", "http2Client", ")", "setGoAwayReason", "(", "f", "*", "http2", ".", "GoAwayFrame", ")", "{", "t", ".", "goAwayReason", "=", "GoAwayNoReason", "\n", "switch", "f", ".", "ErrCode", "{", "case", "http2", ".", "ErrCodeEnhanceYourCalm", "...
// setGoAwayReason sets the value of t.goAwayReason based // on the GoAway frame received. // It expects a lock on transport's mutext to be held by // the caller.
[ "setGoAwayReason", "sets", "the", "value", "of", "t", ".", "goAwayReason", "based", "on", "the", "GoAway", "frame", "received", ".", "It", "expects", "a", "lock", "on", "transport", "s", "mutext", "to", "be", "held", "by", "the", "caller", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L1114-L1122
127,048
grpc/grpc-go
internal/transport/http2_client.go
operateHeaders
func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { s, ok := t.getStream(frame) if !ok { return } endStream := frame.StreamEnded() atomic.StoreUint32(&s.bytesReceived, 1) initialHeader := atomic.SwapUint32(&s.headerDone, 1) == 0 if !initialHeader && !endStream { // As specified by RFC 7540...
go
func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { s, ok := t.getStream(frame) if !ok { return } endStream := frame.StreamEnded() atomic.StoreUint32(&s.bytesReceived, 1) initialHeader := atomic.SwapUint32(&s.headerDone, 1) == 0 if !initialHeader && !endStream { // As specified by RFC 7540...
[ "func", "(", "t", "*", "http2Client", ")", "operateHeaders", "(", "frame", "*", "http2", ".", "MetaHeadersFrame", ")", "{", "s", ",", "ok", ":=", "t", ".", "getStream", "(", "frame", ")", "\n", "if", "!", "ok", "{", "return", "\n", "}", "\n", "endS...
// operateHeaders takes action on the decoded headers.
[ "operateHeaders", "takes", "action", "on", "the", "decoded", "headers", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L1138-L1206
127,049
grpc/grpc-go
internal/transport/http2_client.go
keepalive
func (t *http2Client) keepalive() { p := &ping{data: [8]byte{}} timer := time.NewTimer(t.kp.Time) for { select { case <-timer.C: if atomic.CompareAndSwapUint32(&t.activity, 1, 0) { timer.Reset(t.kp.Time) continue } // Check if keepalive should go dormant. t.mu.Lock() if len(t.activeStreams...
go
func (t *http2Client) keepalive() { p := &ping{data: [8]byte{}} timer := time.NewTimer(t.kp.Time) for { select { case <-timer.C: if atomic.CompareAndSwapUint32(&t.activity, 1, 0) { timer.Reset(t.kp.Time) continue } // Check if keepalive should go dormant. t.mu.Lock() if len(t.activeStreams...
[ "func", "(", "t", "*", "http2Client", ")", "keepalive", "(", ")", "{", "p", ":=", "&", "ping", "{", "data", ":", "[", "8", "]", "byte", "{", "}", "}", "\n", "timer", ":=", "time", ".", "NewTimer", "(", "t", ".", "kp", ".", "Time", ")", "\n", ...
// keepalive running in a separate goroutune makes sure the connection is alive by sending pings.
[ "keepalive", "running", "in", "a", "separate", "goroutune", "makes", "sure", "the", "connection", "is", "alive", "by", "sending", "pings", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_client.go#L1283-L1338
127,050
grpc/grpc-go
naming/dns_resolver.go
NewDNSResolverWithFreq
func NewDNSResolverWithFreq(freq time.Duration) (Resolver, error) { return &dnsResolver{freq: freq}, nil }
go
func NewDNSResolverWithFreq(freq time.Duration) (Resolver, error) { return &dnsResolver{freq: freq}, nil }
[ "func", "NewDNSResolverWithFreq", "(", "freq", "time", ".", "Duration", ")", "(", "Resolver", ",", "error", ")", "{", "return", "&", "dnsResolver", "{", "freq", ":", "freq", "}", ",", "nil", "\n", "}" ]
// NewDNSResolverWithFreq creates a DNS Resolver that can resolve DNS names, and // create watchers that poll the DNS server using the frequency set by freq.
[ "NewDNSResolverWithFreq", "creates", "a", "DNS", "Resolver", "that", "can", "resolve", "DNS", "names", "and", "create", "watchers", "that", "poll", "the", "DNS", "server", "using", "the", "frequency", "set", "by", "freq", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/naming/dns_resolver.go#L47-L49
127,051
grpc/grpc-go
naming/dns_resolver.go
Resolve
func (r *dnsResolver) Resolve(target string) (Watcher, error) { host, port, err := parseTarget(target) if err != nil { return nil, err } if net.ParseIP(host) != nil { ipWatcher := &ipWatcher{ updateChan: make(chan *Update, 1), } host, _ = formatIP(host) ipWatcher.updateChan <- &Update{Op: Add, Addr: h...
go
func (r *dnsResolver) Resolve(target string) (Watcher, error) { host, port, err := parseTarget(target) if err != nil { return nil, err } if net.ParseIP(host) != nil { ipWatcher := &ipWatcher{ updateChan: make(chan *Update, 1), } host, _ = formatIP(host) ipWatcher.updateChan <- &Update{Op: Add, Addr: h...
[ "func", "(", "r", "*", "dnsResolver", ")", "Resolve", "(", "target", "string", ")", "(", "Watcher", ",", "error", ")", "{", "host", ",", "port", ",", "err", ":=", "parseTarget", "(", "target", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ni...
// Resolve creates a watcher that watches the name resolution of the target.
[ "Resolve", "creates", "a", "watcher", "that", "watches", "the", "name", "resolution", "of", "the", "target", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/naming/dns_resolver.go#L116-L140
127,052
grpc/grpc-go
naming/dns_resolver.go
compileUpdate
func (w *dnsWatcher) compileUpdate(newAddrs map[string]*Update) []*Update { var res []*Update for a, u := range w.curAddrs { if _, ok := newAddrs[a]; !ok { u.Op = Delete res = append(res, u) } } for a, u := range newAddrs { if _, ok := w.curAddrs[a]; !ok { res = append(res, u) } } return res }
go
func (w *dnsWatcher) compileUpdate(newAddrs map[string]*Update) []*Update { var res []*Update for a, u := range w.curAddrs { if _, ok := newAddrs[a]; !ok { u.Op = Delete res = append(res, u) } } for a, u := range newAddrs { if _, ok := w.curAddrs[a]; !ok { res = append(res, u) } } return res }
[ "func", "(", "w", "*", "dnsWatcher", ")", "compileUpdate", "(", "newAddrs", "map", "[", "string", "]", "*", "Update", ")", "[", "]", "*", "Update", "{", "var", "res", "[", "]", "*", "Update", "\n", "for", "a", ",", "u", ":=", "range", "w", ".", ...
// compileUpdate compares the old resolved addresses and newly resolved addresses, // and generates an update list
[ "compileUpdate", "compares", "the", "old", "resolved", "addresses", "and", "newly", "resolved", "addresses", "and", "generates", "an", "update", "list" ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/naming/dns_resolver.go#L198-L212
127,053
grpc/grpc-go
examples/features/authentication/server/main.go
valid
func valid(authorization []string) bool { if len(authorization) < 1 { return false } token := strings.TrimPrefix(authorization[0], "Bearer ") // Perform the token validation here. For the sake of this example, the code // here forgoes any of the usual OAuth2 token validation and instead checks // for a token ma...
go
func valid(authorization []string) bool { if len(authorization) < 1 { return false } token := strings.TrimPrefix(authorization[0], "Bearer ") // Perform the token validation here. For the sake of this example, the code // here forgoes any of the usual OAuth2 token validation and instead checks // for a token ma...
[ "func", "valid", "(", "authorization", "[", "]", "string", ")", "bool", "{", "if", "len", "(", "authorization", ")", "<", "1", "{", "return", "false", "\n", "}", "\n", "token", ":=", "strings", ".", "TrimPrefix", "(", "authorization", "[", "0", "]", ...
// valid validates the authorization.
[ "valid", "validates", "the", "authorization", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/authentication/server/main.go#L91-L100
127,054
grpc/grpc-go
examples/features/authentication/server/main.go
ensureValidToken
func ensureValidToken(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { md, ok := metadata.FromIncomingContext(ctx) if !ok { return nil, errMissingMetadata } // The keys within metadata.MD are normalized to lowercase. // See: https://godoc.org/goo...
go
func ensureValidToken(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { md, ok := metadata.FromIncomingContext(ctx) if !ok { return nil, errMissingMetadata } // The keys within metadata.MD are normalized to lowercase. // See: https://godoc.org/goo...
[ "func", "ensureValidToken", "(", "ctx", "context", ".", "Context", ",", "req", "interface", "{", "}", ",", "info", "*", "grpc", ".", "UnaryServerInfo", ",", "handler", "grpc", ".", "UnaryHandler", ")", "(", "interface", "{", "}", ",", "error", ")", "{", ...
// ensureValidToken ensures a valid token exists within a request's metadata. If // the token is missing or invalid, the interceptor blocks execution of the // handler and returns an error. Otherwise, the interceptor invokes the unary // handler.
[ "ensureValidToken", "ensures", "a", "valid", "token", "exists", "within", "a", "request", "s", "metadata", ".", "If", "the", "token", "is", "missing", "or", "invalid", "the", "interceptor", "blocks", "execution", "of", "the", "handler", "and", "returns", "an",...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/examples/features/authentication/server/main.go#L106-L118
127,055
grpc/grpc-go
credentials/alts/internal/conn/aeadrekey.go
newRekeyAEAD
func newRekeyAEAD(key []byte) (*rekeyAEAD, error) { k := len(key) if k != kdfKeyLen+nonceLen { return nil, KeySizeError(k) } return &rekeyAEAD{ kdfKey: key[:kdfKeyLen], kdfCounter: make([]byte, kdfCounterLen), nonceMask: key[kdfKeyLen:], nonceBuf: make([]byte, nonceLen), gcmAEAD: nil, }, nil ...
go
func newRekeyAEAD(key []byte) (*rekeyAEAD, error) { k := len(key) if k != kdfKeyLen+nonceLen { return nil, KeySizeError(k) } return &rekeyAEAD{ kdfKey: key[:kdfKeyLen], kdfCounter: make([]byte, kdfCounterLen), nonceMask: key[kdfKeyLen:], nonceBuf: make([]byte, nonceLen), gcmAEAD: nil, }, nil ...
[ "func", "newRekeyAEAD", "(", "key", "[", "]", "byte", ")", "(", "*", "rekeyAEAD", ",", "error", ")", "{", "k", ":=", "len", "(", "key", ")", "\n", "if", "k", "!=", "kdfKeyLen", "+", "nonceLen", "{", "return", "nil", ",", "KeySizeError", "(", "k", ...
// newRekeyAEAD creates a new instance of aes128gcm with rekeying. // The key argument should be 44 bytes, the first 32 bytes are used as a key // for HKDF-expand and the remainining 12 bytes are used as a random mask for // the counter.
[ "newRekeyAEAD", "creates", "a", "new", "instance", "of", "aes128gcm", "with", "rekeying", ".", "The", "key", "argument", "should", "be", "44", "bytes", "the", "first", "32", "bytes", "are", "used", "as", "a", "key", "for", "HKDF", "-", "expand", "and", "...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aeadrekey.go#L54-L66
127,056
grpc/grpc-go
credentials/alts/internal/conn/aeadrekey.go
rekeyIfRequired
func (s *rekeyAEAD) rekeyIfRequired(nonce []byte) error { newKdfCounter := nonce[kdfCounterOffset : kdfCounterOffset+kdfCounterLen] if s.gcmAEAD != nil && bytes.Equal(newKdfCounter, s.kdfCounter) { return nil } copy(s.kdfCounter, newKdfCounter) a, err := aes.NewCipher(hkdfExpand(s.kdfKey, s.kdfCounter)) if err ...
go
func (s *rekeyAEAD) rekeyIfRequired(nonce []byte) error { newKdfCounter := nonce[kdfCounterOffset : kdfCounterOffset+kdfCounterLen] if s.gcmAEAD != nil && bytes.Equal(newKdfCounter, s.kdfCounter) { return nil } copy(s.kdfCounter, newKdfCounter) a, err := aes.NewCipher(hkdfExpand(s.kdfKey, s.kdfCounter)) if err ...
[ "func", "(", "s", "*", "rekeyAEAD", ")", "rekeyIfRequired", "(", "nonce", "[", "]", "byte", ")", "error", "{", "newKdfCounter", ":=", "nonce", "[", "kdfCounterOffset", ":", "kdfCounterOffset", "+", "kdfCounterLen", "]", "\n", "if", "s", ".", "gcmAEAD", "!=...
// rekeyIfRequired creates a new aes128gcm AEAD if the existing AEAD is nil // or cannot be used with given nonce.
[ "rekeyIfRequired", "creates", "a", "new", "aes128gcm", "AEAD", "if", "the", "existing", "AEAD", "is", "nil", "or", "cannot", "be", "used", "with", "given", "nonce", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aeadrekey.go#L90-L102
127,057
grpc/grpc-go
credentials/alts/internal/conn/aeadrekey.go
maskNonce
func maskNonce(dst, nonce, mask []byte) { nonce1 := binary.LittleEndian.Uint64(nonce[:sizeUint64]) nonce2 := binary.LittleEndian.Uint32(nonce[sizeUint64:]) mask1 := binary.LittleEndian.Uint64(mask[:sizeUint64]) mask2 := binary.LittleEndian.Uint32(mask[sizeUint64:]) binary.LittleEndian.PutUint64(dst[:sizeUint64], n...
go
func maskNonce(dst, nonce, mask []byte) { nonce1 := binary.LittleEndian.Uint64(nonce[:sizeUint64]) nonce2 := binary.LittleEndian.Uint32(nonce[sizeUint64:]) mask1 := binary.LittleEndian.Uint64(mask[:sizeUint64]) mask2 := binary.LittleEndian.Uint32(mask[sizeUint64:]) binary.LittleEndian.PutUint64(dst[:sizeUint64], n...
[ "func", "maskNonce", "(", "dst", ",", "nonce", ",", "mask", "[", "]", "byte", ")", "{", "nonce1", ":=", "binary", ".", "LittleEndian", ".", "Uint64", "(", "nonce", "[", ":", "sizeUint64", "]", ")", "\n", "nonce2", ":=", "binary", ".", "LittleEndian", ...
// maskNonce XORs the given nonce with the mask and stores the result in dst.
[ "maskNonce", "XORs", "the", "given", "nonce", "with", "the", "mask", "and", "stores", "the", "result", "in", "dst", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aeadrekey.go#L105-L112
127,058
grpc/grpc-go
credentials/alts/internal/conn/aeadrekey.go
hkdfExpand
func hkdfExpand(key, info []byte) []byte { mac := hmac.New(sha256.New, key) mac.Write(info) mac.Write([]byte{0x01}[:]) return mac.Sum(nil)[:aeadKeyLen] }
go
func hkdfExpand(key, info []byte) []byte { mac := hmac.New(sha256.New, key) mac.Write(info) mac.Write([]byte{0x01}[:]) return mac.Sum(nil)[:aeadKeyLen] }
[ "func", "hkdfExpand", "(", "key", ",", "info", "[", "]", "byte", ")", "[", "]", "byte", "{", "mac", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "key", ")", "\n", "mac", ".", "Write", "(", "info", ")", "\n", "mac", ".", "Write", ...
// hkdfExpand computes the first 16 bytes of the HKDF-expand function // defined in RFC5869.
[ "hkdfExpand", "computes", "the", "first", "16", "bytes", "of", "the", "HKDF", "-", "expand", "function", "defined", "in", "RFC5869", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/credentials/alts/internal/conn/aeadrekey.go#L126-L131
127,059
grpc/grpc-go
status/status.go
Code
func (s *Status) Code() codes.Code { if s == nil || s.s == nil { return codes.OK } return codes.Code(s.s.Code) }
go
func (s *Status) Code() codes.Code { if s == nil || s.s == nil { return codes.OK } return codes.Code(s.s.Code) }
[ "func", "(", "s", "*", "Status", ")", "Code", "(", ")", "codes", ".", "Code", "{", "if", "s", "==", "nil", "||", "s", ".", "s", "==", "nil", "{", "return", "codes", ".", "OK", "\n", "}", "\n", "return", "codes", ".", "Code", "(", "s", ".", ...
// Code returns the status code contained in s.
[ "Code", "returns", "the", "status", "code", "contained", "in", "s", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/status/status.go#L61-L66
127,060
grpc/grpc-go
status/status.go
Message
func (s *Status) Message() string { if s == nil || s.s == nil { return "" } return s.s.Message }
go
func (s *Status) Message() string { if s == nil || s.s == nil { return "" } return s.s.Message }
[ "func", "(", "s", "*", "Status", ")", "Message", "(", ")", "string", "{", "if", "s", "==", "nil", "||", "s", ".", "s", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "s", ".", "s", ".", "Message", "\n", "}" ]
// Message returns the message contained in s.
[ "Message", "returns", "the", "message", "contained", "in", "s", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/status/status.go#L69-L74
127,061
grpc/grpc-go
status/status.go
Proto
func (s *Status) Proto() *spb.Status { if s == nil { return nil } return proto.Clone(s.s).(*spb.Status) }
go
func (s *Status) Proto() *spb.Status { if s == nil { return nil } return proto.Clone(s.s).(*spb.Status) }
[ "func", "(", "s", "*", "Status", ")", "Proto", "(", ")", "*", "spb", ".", "Status", "{", "if", "s", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "proto", ".", "Clone", "(", "s", ".", "s", ")", ".", "(", "*", "spb", ".", "St...
// Proto returns s's status as an spb.Status proto message.
[ "Proto", "returns", "s", "s", "status", "as", "an", "spb", ".", "Status", "proto", "message", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/status/status.go#L77-L82
127,062
grpc/grpc-go
status/status.go
Error
func Error(c codes.Code, msg string) error { return New(c, msg).Err() }
go
func Error(c codes.Code, msg string) error { return New(c, msg).Err() }
[ "func", "Error", "(", "c", "codes", ".", "Code", ",", "msg", "string", ")", "error", "{", "return", "New", "(", "c", ",", "msg", ")", ".", "Err", "(", ")", "\n", "}" ]
// Error returns an error representing c and msg. If c is OK, returns nil.
[ "Error", "returns", "an", "error", "representing", "c", "and", "msg", ".", "If", "c", "is", "OK", "returns", "nil", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/status/status.go#L104-L106
127,063
grpc/grpc-go
status/status.go
FromContextError
func FromContextError(err error) *Status { switch err { case nil: return New(codes.OK, "") case context.DeadlineExceeded: return New(codes.DeadlineExceeded, err.Error()) case context.Canceled: return New(codes.Canceled, err.Error()) default: return New(codes.Unknown, err.Error()) } }
go
func FromContextError(err error) *Status { switch err { case nil: return New(codes.OK, "") case context.DeadlineExceeded: return New(codes.DeadlineExceeded, err.Error()) case context.Canceled: return New(codes.Canceled, err.Error()) default: return New(codes.Unknown, err.Error()) } }
[ "func", "FromContextError", "(", "err", "error", ")", "*", "Status", "{", "switch", "err", "{", "case", "nil", ":", "return", "New", "(", "codes", ".", "OK", ",", "\"", "\"", ")", "\n", "case", "context", ".", "DeadlineExceeded", ":", "return", "New", ...
// FromContextError converts a context error into a Status. It returns a // Status with codes.OK if err is nil, or a Status with codes.Unknown if err is // non-nil and not a context error.
[ "FromContextError", "converts", "a", "context", "error", "into", "a", "Status", ".", "It", "returns", "a", "Status", "with", "codes", ".", "OK", "if", "err", "is", "nil", "or", "a", "Status", "with", "codes", ".", "Unknown", "if", "err", "is", "non", "...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/status/status.go#L199-L210
127,064
grpc/grpc-go
resolver/resolver.go
Get
func Get(scheme string) Builder { if b, ok := m[scheme]; ok { return b } return nil }
go
func Get(scheme string) Builder { if b, ok := m[scheme]; ok { return b } return nil }
[ "func", "Get", "(", "scheme", "string", ")", "Builder", "{", "if", "b", ",", "ok", ":=", "m", "[", "scheme", "]", ";", "ok", "{", "return", "b", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Get returns the resolver builder registered with the given scheme. // // If no builder is register with the scheme, nil will be returned.
[ "Get", "returns", "the", "resolver", "builder", "registered", "with", "the", "given", "scheme", ".", "If", "no", "builder", "is", "register", "with", "the", "scheme", "nil", "will", "be", "returned", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/resolver/resolver.go#L45-L50
127,065
grpc/grpc-go
clientconn.go
Dial
func Dial(target string, opts ...DialOption) (*ClientConn, error) { return DialContext(context.Background(), target, opts...) }
go
func Dial(target string, opts ...DialOption) (*ClientConn, error) { return DialContext(context.Background(), target, opts...) }
[ "func", "Dial", "(", "target", "string", ",", "opts", "...", "DialOption", ")", "(", "*", "ClientConn", ",", "error", ")", "{", "return", "DialContext", "(", "context", ".", "Background", "(", ")", ",", "target", ",", "opts", "...", ")", "\n", "}" ]
// Dial creates a client connection to the given target.
[ "Dial", "creates", "a", "client", "connection", "to", "the", "given", "target", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L103-L105
127,066
grpc/grpc-go
clientconn.go
chainUnaryClientInterceptors
func chainUnaryClientInterceptors(cc *ClientConn) { interceptors := cc.dopts.chainUnaryInts // Prepend dopts.unaryInt to the chaining interceptors if it exists, since unaryInt will // be executed before any other chained interceptors. if cc.dopts.unaryInt != nil { interceptors = append([]UnaryClientInterceptor{cc...
go
func chainUnaryClientInterceptors(cc *ClientConn) { interceptors := cc.dopts.chainUnaryInts // Prepend dopts.unaryInt to the chaining interceptors if it exists, since unaryInt will // be executed before any other chained interceptors. if cc.dopts.unaryInt != nil { interceptors = append([]UnaryClientInterceptor{cc...
[ "func", "chainUnaryClientInterceptors", "(", "cc", "*", "ClientConn", ")", "{", "interceptors", ":=", "cc", ".", "dopts", ".", "chainUnaryInts", "\n", "// Prepend dopts.unaryInt to the chaining interceptors if it exists, since unaryInt will", "// be executed before any other chaine...
// chainUnaryClientInterceptors chains all unary client interceptors into one.
[ "chainUnaryClientInterceptors", "chains", "all", "unary", "client", "interceptors", "into", "one", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L334-L352
127,067
grpc/grpc-go
clientconn.go
getChainUnaryInvoker
func getChainUnaryInvoker(interceptors []UnaryClientInterceptor, curr int, finalInvoker UnaryInvoker) UnaryInvoker { if curr == len(interceptors)-1 { return finalInvoker } return func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error { return interceptors[curr+...
go
func getChainUnaryInvoker(interceptors []UnaryClientInterceptor, curr int, finalInvoker UnaryInvoker) UnaryInvoker { if curr == len(interceptors)-1 { return finalInvoker } return func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error { return interceptors[curr+...
[ "func", "getChainUnaryInvoker", "(", "interceptors", "[", "]", "UnaryClientInterceptor", ",", "curr", "int", ",", "finalInvoker", "UnaryInvoker", ")", "UnaryInvoker", "{", "if", "curr", "==", "len", "(", "interceptors", ")", "-", "1", "{", "return", "finalInvoke...
// getChainUnaryInvoker recursively generate the chained unary invoker.
[ "getChainUnaryInvoker", "recursively", "generate", "the", "chained", "unary", "invoker", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L355-L362
127,068
grpc/grpc-go
clientconn.go
chainStreamClientInterceptors
func chainStreamClientInterceptors(cc *ClientConn) { interceptors := cc.dopts.chainStreamInts // Prepend dopts.streamInt to the chaining interceptors if it exists, since streamInt will // be executed before any other chained interceptors. if cc.dopts.streamInt != nil { interceptors = append([]StreamClientIntercep...
go
func chainStreamClientInterceptors(cc *ClientConn) { interceptors := cc.dopts.chainStreamInts // Prepend dopts.streamInt to the chaining interceptors if it exists, since streamInt will // be executed before any other chained interceptors. if cc.dopts.streamInt != nil { interceptors = append([]StreamClientIntercep...
[ "func", "chainStreamClientInterceptors", "(", "cc", "*", "ClientConn", ")", "{", "interceptors", ":=", "cc", ".", "dopts", ".", "chainStreamInts", "\n", "// Prepend dopts.streamInt to the chaining interceptors if it exists, since streamInt will", "// be executed before any other ch...
// chainStreamClientInterceptors chains all stream client interceptors into one.
[ "chainStreamClientInterceptors", "chains", "all", "stream", "client", "interceptors", "into", "one", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L365-L383
127,069
grpc/grpc-go
clientconn.go
getChainStreamer
func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStreamer Streamer) Streamer { if curr == len(interceptors)-1 { return finalStreamer } return func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) { return interceptors[curr...
go
func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStreamer Streamer) Streamer { if curr == len(interceptors)-1 { return finalStreamer } return func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) { return interceptors[curr...
[ "func", "getChainStreamer", "(", "interceptors", "[", "]", "StreamClientInterceptor", ",", "curr", "int", ",", "finalStreamer", "Streamer", ")", "Streamer", "{", "if", "curr", "==", "len", "(", "interceptors", ")", "-", "1", "{", "return", "finalStreamer", "\n...
// getChainStreamer recursively generate the chained client stream constructor.
[ "getChainStreamer", "recursively", "generate", "the", "chained", "client", "stream", "constructor", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L386-L393
127,070
grpc/grpc-go
clientconn.go
updateState
func (csm *connectivityStateManager) updateState(state connectivity.State) { csm.mu.Lock() defer csm.mu.Unlock() if csm.state == connectivity.Shutdown { return } if csm.state == state { return } csm.state = state if channelz.IsOn() { channelz.AddTraceEvent(csm.channelzID, &channelz.TraceEventDesc{ Desc...
go
func (csm *connectivityStateManager) updateState(state connectivity.State) { csm.mu.Lock() defer csm.mu.Unlock() if csm.state == connectivity.Shutdown { return } if csm.state == state { return } csm.state = state if channelz.IsOn() { channelz.AddTraceEvent(csm.channelzID, &channelz.TraceEventDesc{ Desc...
[ "func", "(", "csm", "*", "connectivityStateManager", ")", "updateState", "(", "state", "connectivity", ".", "State", ")", "{", "csm", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "csm", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "csm", ".", ...
// updateState updates the connectivity.State of ClientConn. // If there's a change it notifies goroutines waiting on state change to // happen.
[ "updateState", "updates", "the", "connectivity", ".", "State", "of", "ClientConn", ".", "If", "there", "s", "a", "change", "it", "notifies", "goroutines", "waiting", "on", "state", "change", "to", "happen", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L407-L428
127,071
grpc/grpc-go
clientconn.go
WaitForStateChange
func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState connectivity.State) bool { ch := cc.csMgr.getNotifyChan() if cc.csMgr.getState() != sourceState { return true } select { case <-ctx.Done(): return false case <-ch: return true } }
go
func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState connectivity.State) bool { ch := cc.csMgr.getNotifyChan() if cc.csMgr.getState() != sourceState { return true } select { case <-ctx.Done(): return false case <-ch: return true } }
[ "func", "(", "cc", "*", "ClientConn", ")", "WaitForStateChange", "(", "ctx", "context", ".", "Context", ",", "sourceState", "connectivity", ".", "State", ")", "bool", "{", "ch", ":=", "cc", ".", "csMgr", ".", "getNotifyChan", "(", ")", "\n", "if", "cc", ...
// WaitForStateChange waits until the connectivity.State of ClientConn changes from sourceState or // ctx expires. A true value is returned in former case and false in latter. // This is an EXPERIMENTAL API.
[ "WaitForStateChange", "waits", "until", "the", "connectivity", ".", "State", "of", "ClientConn", "changes", "from", "sourceState", "or", "ctx", "expires", ".", "A", "true", "value", "is", "returned", "in", "former", "case", "and", "false", "in", "latter", ".",...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L478-L489
127,072
grpc/grpc-go
clientconn.go
waitForResolvedAddrs
func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error { // This is on the RPC path, so we use a fast path to avoid the // more-expensive "select" below after the resolver has returned once. if cc.firstResolveEvent.HasFired() { return nil } select { case <-cc.firstResolveEvent.Done(): return ni...
go
func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error { // This is on the RPC path, so we use a fast path to avoid the // more-expensive "select" below after the resolver has returned once. if cc.firstResolveEvent.HasFired() { return nil } select { case <-cc.firstResolveEvent.Done(): return ni...
[ "func", "(", "cc", "*", "ClientConn", ")", "waitForResolvedAddrs", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// This is on the RPC path, so we use a fast path to avoid the", "// more-expensive \"select\" below after the resolver has returned once.", "if", "cc", ...
// waitForResolvedAddrs blocks until the resolver has provided addresses or the // context expires. Returns nil unless the context expires first; otherwise // returns a status error based on the context.
[ "waitForResolvedAddrs", "blocks", "until", "the", "resolver", "has", "provided", "addresses", "or", "the", "context", "expires", ".", "Returns", "nil", "unless", "the", "context", "expires", "first", ";", "otherwise", "returns", "a", "status", "error", "based", ...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L518-L532
127,073
grpc/grpc-go
clientconn.go
switchBalancer
func (cc *ClientConn) switchBalancer(name string) { if strings.ToLower(cc.curBalancerName) == strings.ToLower(name) { return } grpclog.Infof("ClientConn switching balancer to %q", name) if cc.dopts.balancerBuilder != nil { grpclog.Infoln("ignoring balancer switching: Balancer DialOption used instead") return...
go
func (cc *ClientConn) switchBalancer(name string) { if strings.ToLower(cc.curBalancerName) == strings.ToLower(name) { return } grpclog.Infof("ClientConn switching balancer to %q", name) if cc.dopts.balancerBuilder != nil { grpclog.Infoln("ignoring balancer switching: Balancer DialOption used instead") return...
[ "func", "(", "cc", "*", "ClientConn", ")", "switchBalancer", "(", "name", "string", ")", "{", "if", "strings", ".", "ToLower", "(", "cc", ".", "curBalancerName", ")", "==", "strings", ".", "ToLower", "(", "name", ")", "{", "return", "\n", "}", "\n\n", ...
// switchBalancer starts the switching from current balancer to the balancer // with the given name. // // It will NOT send the current address list to the new balancer. If needed, // caller of this function should send address list to the new balancer after // this function returns. // // Caller must hold cc.mu.
[ "switchBalancer", "starts", "the", "switching", "from", "current", "balancer", "to", "the", "balancer", "with", "the", "given", "name", ".", "It", "will", "NOT", "send", "the", "current", "address", "list", "to", "the", "new", "balancer", ".", "If", "needed"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L621-L656
127,074
grpc/grpc-go
clientconn.go
removeAddrConn
func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) { cc.mu.Lock() if cc.conns == nil { cc.mu.Unlock() return } delete(cc.conns, ac) cc.mu.Unlock() ac.tearDown(err) }
go
func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) { cc.mu.Lock() if cc.conns == nil { cc.mu.Unlock() return } delete(cc.conns, ac) cc.mu.Unlock() ac.tearDown(err) }
[ "func", "(", "cc", "*", "ClientConn", ")", "removeAddrConn", "(", "ac", "*", "addrConn", ",", "err", "error", ")", "{", "cc", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "cc", ".", "conns", "==", "nil", "{", "cc", ".", "mu", ".", "Unlock", "(...
// removeAddrConn removes the addrConn in the subConn from clientConn. // It also tears down the ac with the given error.
[ "removeAddrConn", "removes", "the", "addrConn", "in", "the", "subConn", "from", "clientConn", ".", "It", "also", "tears", "down", "the", "ac", "with", "the", "given", "error", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L707-L716
127,075
grpc/grpc-go
clientconn.go
tryUpdateAddrs
func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool { ac.mu.Lock() defer ac.mu.Unlock() grpclog.Infof("addrConn: tryUpdateAddrs curAddr: %v, addrs: %v", ac.curAddr, addrs) if ac.state == connectivity.Shutdown { ac.addrs = addrs return true } // Unless we're busy reconnecting already, let's reco...
go
func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool { ac.mu.Lock() defer ac.mu.Unlock() grpclog.Infof("addrConn: tryUpdateAddrs curAddr: %v, addrs: %v", ac.curAddr, addrs) if ac.state == connectivity.Shutdown { ac.addrs = addrs return true } // Unless we're busy reconnecting already, let's reco...
[ "func", "(", "ac", "*", "addrConn", ")", "tryUpdateAddrs", "(", "addrs", "[", "]", "resolver", ".", "Address", ")", "bool", "{", "ac", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ac", ".", "mu", ".", "Unlock", "(", ")", "\n", "grpclog", "."...
// tryUpdateAddrs tries to update ac.addrs with the new addresses list. // // It checks whether current connected address of ac is in the new addrs list. // - If true, it updates ac.addrs and returns true. The ac will keep using // the existing connection. // - If false, it does nothing and returns false.
[ "tryUpdateAddrs", "tries", "to", "update", "ac", ".", "addrs", "with", "the", "new", "addresses", "list", ".", "It", "checks", "whether", "current", "connected", "address", "of", "ac", "is", "in", "the", "new", "addrs", "list", ".", "-", "If", "true", "i...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L775-L803
127,076
grpc/grpc-go
clientconn.go
ResetConnectBackoff
func (cc *ClientConn) ResetConnectBackoff() { cc.mu.Lock() defer cc.mu.Unlock() for ac := range cc.conns { ac.resetConnectBackoff() } }
go
func (cc *ClientConn) ResetConnectBackoff() { cc.mu.Lock() defer cc.mu.Unlock() for ac := range cc.conns { ac.resetConnectBackoff() } }
[ "func", "(", "cc", "*", "ClientConn", ")", "ResetConnectBackoff", "(", ")", "{", "cc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "cc", ".", "mu", ".", "Unlock", "(", ")", "\n", "for", "ac", ":=", "range", "cc", ".", "conns", "{", "ac", "...
// ResetConnectBackoff wakes up all subchannels in transient failure and causes // them to attempt another connection immediately. It also resets the backoff // times used for subsequent attempts regardless of the current state. // // In general, this function should not be used. Typical service or network // outages...
[ "ResetConnectBackoff", "wakes", "up", "all", "subchannels", "in", "transient", "failure", "and", "causes", "them", "to", "attempt", "another", "connection", "immediately", ".", "It", "also", "resets", "the", "backoff", "times", "used", "for", "subsequent", "attemp...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L888-L894
127,077
grpc/grpc-go
clientconn.go
Close
func (cc *ClientConn) Close() error { defer cc.cancel() cc.mu.Lock() if cc.conns == nil { cc.mu.Unlock() return ErrClientConnClosing } conns := cc.conns cc.conns = nil cc.csMgr.updateState(connectivity.Shutdown) rWrapper := cc.resolverWrapper cc.resolverWrapper = nil bWrapper := cc.balancerWrapper cc.b...
go
func (cc *ClientConn) Close() error { defer cc.cancel() cc.mu.Lock() if cc.conns == nil { cc.mu.Unlock() return ErrClientConnClosing } conns := cc.conns cc.conns = nil cc.csMgr.updateState(connectivity.Shutdown) rWrapper := cc.resolverWrapper cc.resolverWrapper = nil bWrapper := cc.balancerWrapper cc.b...
[ "func", "(", "cc", "*", "ClientConn", ")", "Close", "(", ")", "error", "{", "defer", "cc", ".", "cancel", "(", ")", "\n\n", "cc", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "cc", ".", "conns", "==", "nil", "{", "cc", ".", "mu", ".", "Unloc...
// Close tears down the ClientConn and all underlying connections.
[ "Close", "tears", "down", "the", "ClientConn", "and", "all", "underlying", "connections", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L897-L944
127,078
grpc/grpc-go
clientconn.go
adjustParams
func (ac *addrConn) adjustParams(r transport.GoAwayReason) { switch r { case transport.GoAwayTooManyPings: v := 2 * ac.dopts.copts.KeepaliveParams.Time ac.cc.mu.Lock() if v > ac.cc.mkp.Time { ac.cc.mkp.Time = v } ac.cc.mu.Unlock() } }
go
func (ac *addrConn) adjustParams(r transport.GoAwayReason) { switch r { case transport.GoAwayTooManyPings: v := 2 * ac.dopts.copts.KeepaliveParams.Time ac.cc.mu.Lock() if v > ac.cc.mkp.Time { ac.cc.mkp.Time = v } ac.cc.mu.Unlock() } }
[ "func", "(", "ac", "*", "addrConn", ")", "adjustParams", "(", "r", "transport", ".", "GoAwayReason", ")", "{", "switch", "r", "{", "case", "transport", ".", "GoAwayTooManyPings", ":", "v", ":=", "2", "*", "ac", ".", "dopts", ".", "copts", ".", "Keepali...
// adjustParams updates parameters used to create transports upon // receiving a GoAway.
[ "adjustParams", "updates", "parameters", "used", "to", "create", "transports", "upon", "receiving", "a", "GoAway", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L995-L1005
127,079
grpc/grpc-go
clientconn.go
tryAllAddrs
func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.Time) (transport.ClientTransport, resolver.Address, *grpcsync.Event, error) { for _, addr := range addrs { ac.mu.Lock() if ac.state == connectivity.Shutdown { ac.mu.Unlock() return nil, resolver.Address{}, nil, errConnClosing } ...
go
func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.Time) (transport.ClientTransport, resolver.Address, *grpcsync.Event, error) { for _, addr := range addrs { ac.mu.Lock() if ac.state == connectivity.Shutdown { ac.mu.Unlock() return nil, resolver.Address{}, nil, errConnClosing } ...
[ "func", "(", "ac", "*", "addrConn", ")", "tryAllAddrs", "(", "addrs", "[", "]", "resolver", ".", "Address", ",", "connectDeadline", "time", ".", "Time", ")", "(", "transport", ".", "ClientTransport", ",", "resolver", ".", "Address", ",", "*", "grpcsync", ...
// tryAllAddrs tries to creates a connection to the addresses, and stop when at the // first successful one. It returns the transport, the address and a Event in // the successful case. The Event fires when the returned transport disconnects.
[ "tryAllAddrs", "tries", "to", "creates", "a", "connection", "to", "the", "addresses", "and", "stop", "when", "at", "the", "first", "successful", "one", ".", "It", "returns", "the", "transport", "the", "address", "and", "a", "Event", "in", "the", "successful"...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L1127-L1163
127,080
grpc/grpc-go
clientconn.go
createTransport
func (ac *addrConn) createTransport(addr resolver.Address, copts transport.ConnectOptions, connectDeadline time.Time) (transport.ClientTransport, *grpcsync.Event, error) { prefaceReceived := make(chan struct{}) onCloseCalled := make(chan struct{}) reconnect := grpcsync.NewEvent() target := transport.TargetInfo{ ...
go
func (ac *addrConn) createTransport(addr resolver.Address, copts transport.ConnectOptions, connectDeadline time.Time) (transport.ClientTransport, *grpcsync.Event, error) { prefaceReceived := make(chan struct{}) onCloseCalled := make(chan struct{}) reconnect := grpcsync.NewEvent() target := transport.TargetInfo{ ...
[ "func", "(", "ac", "*", "addrConn", ")", "createTransport", "(", "addr", "resolver", ".", "Address", ",", "copts", "transport", ".", "ConnectOptions", ",", "connectDeadline", "time", ".", "Time", ")", "(", "transport", ".", "ClientTransport", ",", "*", "grpc...
// createTransport creates a connection to addr. It returns the transport and a // Event in the successful case. The Event fires when the returned transport // disconnects.
[ "createTransport", "creates", "a", "connection", "to", "addr", ".", "It", "returns", "the", "transport", "and", "a", "Event", "in", "the", "successful", "case", ".", "The", "Event", "fires", "when", "the", "returned", "transport", "disconnects", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L1168-L1224
127,081
grpc/grpc-go
clientconn.go
getReadyTransport
func (ac *addrConn) getReadyTransport() (transport.ClientTransport, bool) { ac.mu.Lock() if ac.state == connectivity.Ready && ac.transport != nil { t := ac.transport ac.mu.Unlock() return t, true } var idle bool if ac.state == connectivity.Idle { idle = true } ac.mu.Unlock() // Trigger idle ac to connec...
go
func (ac *addrConn) getReadyTransport() (transport.ClientTransport, bool) { ac.mu.Lock() if ac.state == connectivity.Ready && ac.transport != nil { t := ac.transport ac.mu.Unlock() return t, true } var idle bool if ac.state == connectivity.Idle { idle = true } ac.mu.Unlock() // Trigger idle ac to connec...
[ "func", "(", "ac", "*", "addrConn", ")", "getReadyTransport", "(", ")", "(", "transport", ".", "ClientTransport", ",", "bool", ")", "{", "ac", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "ac", ".", "state", "==", "connectivity", ".", "Ready", "&&",...
// getReadyTransport returns the transport if ac's state is READY. // Otherwise it returns nil, false. // If ac's state is IDLE, it will trigger ac to connect.
[ "getReadyTransport", "returns", "the", "transport", "if", "ac", "s", "state", "is", "READY", ".", "Otherwise", "it", "returns", "nil", "false", ".", "If", "ac", "s", "state", "is", "IDLE", "it", "will", "trigger", "ac", "to", "connect", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/clientconn.go#L1275-L1292
127,082
grpc/grpc-go
stats/stats.go
OutgoingTags
func OutgoingTags(ctx context.Context) []byte { b, _ := ctx.Value(outgoingTagsKey{}).([]byte) return b }
go
func OutgoingTags(ctx context.Context) []byte { b, _ := ctx.Value(outgoingTagsKey{}).([]byte) return b }
[ "func", "OutgoingTags", "(", "ctx", "context", ".", "Context", ")", "[", "]", "byte", "{", "b", ",", "_", ":=", "ctx", ".", "Value", "(", "outgoingTagsKey", "{", "}", ")", ".", "(", "[", "]", "byte", ")", "\n", "return", "b", "\n", "}" ]
// OutgoingTags returns the tags from the context for the outbound RPC. // // This is intended for gRPC-internal use ONLY.
[ "OutgoingTags", "returns", "the", "tags", "from", "the", "context", "for", "the", "outbound", "RPC", ".", "This", "is", "intended", "for", "gRPC", "-", "internal", "use", "ONLY", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stats/stats.go#L257-L260
127,083
grpc/grpc-go
stats/stats.go
OutgoingTrace
func OutgoingTrace(ctx context.Context) []byte { b, _ := ctx.Value(outgoingTraceKey{}).([]byte) return b }
go
func OutgoingTrace(ctx context.Context) []byte { b, _ := ctx.Value(outgoingTraceKey{}).([]byte) return b }
[ "func", "OutgoingTrace", "(", "ctx", "context", ".", "Context", ")", "[", "]", "byte", "{", "b", ",", "_", ":=", "ctx", ".", "Value", "(", "outgoingTraceKey", "{", "}", ")", ".", "(", "[", "]", "byte", ")", "\n", "return", "b", "\n", "}" ]
// OutgoingTrace returns the trace from the context for the outbound RPC. It is // intended for gRPC-internal use.
[ "OutgoingTrace", "returns", "the", "trace", "from", "the", "context", "for", "the", "outbound", "RPC", ".", "It", "is", "intended", "for", "gRPC", "-", "internal", "use", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/stats/stats.go#L297-L300
127,084
grpc/grpc-go
internal/transport/http2_server.go
HandleStreams
func (t *http2Server) HandleStreams(handle func(*Stream), traceCtx func(context.Context, string) context.Context) { defer close(t.readerDone) for { frame, err := t.framer.fr.ReadFrame() atomic.StoreUint32(&t.activity, 1) if err != nil { if se, ok := err.(http2.StreamError); ok { warningf("transport: http...
go
func (t *http2Server) HandleStreams(handle func(*Stream), traceCtx func(context.Context, string) context.Context) { defer close(t.readerDone) for { frame, err := t.framer.fr.ReadFrame() atomic.StoreUint32(&t.activity, 1) if err != nil { if se, ok := err.(http2.StreamError); ok { warningf("transport: http...
[ "func", "(", "t", "*", "http2Server", ")", "HandleStreams", "(", "handle", "func", "(", "*", "Stream", ")", ",", "traceCtx", "func", "(", "context", ".", "Context", ",", "string", ")", "context", ".", "Context", ")", "{", "defer", "close", "(", "t", ...
// HandleStreams receives incoming streams using the given handler. This is // typically run in a separate goroutine. // traceCtx attaches trace to ctx and returns the new context.
[ "HandleStreams", "receives", "incoming", "streams", "using", "the", "given", "handler", ".", "This", "is", "typically", "run", "in", "a", "separate", "goroutine", ".", "traceCtx", "attaches", "trace", "to", "ctx", "and", "returns", "the", "new", "context", "."...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L428-L481
127,085
grpc/grpc-go
internal/transport/http2_server.go
adjustWindow
func (t *http2Server) adjustWindow(s *Stream, n uint32) { if w := s.fc.maybeAdjust(n); w > 0 { t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) } }
go
func (t *http2Server) adjustWindow(s *Stream, n uint32) { if w := s.fc.maybeAdjust(n); w > 0 { t.controlBuf.put(&outgoingWindowUpdate{streamID: s.id, increment: w}) } }
[ "func", "(", "t", "*", "http2Server", ")", "adjustWindow", "(", "s", "*", "Stream", ",", "n", "uint32", ")", "{", "if", "w", ":=", "s", ".", "fc", ".", "maybeAdjust", "(", "n", ")", ";", "w", ">", "0", "{", "t", ".", "controlBuf", ".", "put", ...
// adjustWindow sends out extra window update over the initial window size // of stream if the application is requesting data larger in size than // the window.
[ "adjustWindow", "sends", "out", "extra", "window", "update", "over", "the", "initial", "window", "size", "of", "stream", "if", "the", "application", "is", "requesting", "data", "larger", "in", "size", "than", "the", "window", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L501-L506
127,086
grpc/grpc-go
internal/transport/http2_server.go
updateFlowControl
func (t *http2Server) updateFlowControl(n uint32) { t.mu.Lock() for _, s := range t.activeStreams { s.fc.newLimit(n) } t.initialWindowSize = int32(n) t.mu.Unlock() t.controlBuf.put(&outgoingWindowUpdate{ streamID: 0, increment: t.fc.newLimit(n), }) t.controlBuf.put(&outgoingSettings{ ss: []http2.Settin...
go
func (t *http2Server) updateFlowControl(n uint32) { t.mu.Lock() for _, s := range t.activeStreams { s.fc.newLimit(n) } t.initialWindowSize = int32(n) t.mu.Unlock() t.controlBuf.put(&outgoingWindowUpdate{ streamID: 0, increment: t.fc.newLimit(n), }) t.controlBuf.put(&outgoingSettings{ ss: []http2.Settin...
[ "func", "(", "t", "*", "http2Server", ")", "updateFlowControl", "(", "n", "uint32", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "_", ",", "s", ":=", "range", "t", ".", "activeStreams", "{", "s", ".", "fc", ".", "newLimit", "(", ...
// updateFlowControl updates the incoming flow control windows // for the transport and the stream based on the current bdp // estimation.
[ "updateFlowControl", "updates", "the", "incoming", "flow", "control", "windows", "for", "the", "transport", "and", "the", "stream", "based", "on", "the", "current", "bdp", "estimation", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L522-L542
127,087
grpc/grpc-go
internal/transport/http2_server.go
WriteHeader
func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error { if s.updateHeaderSent() || s.getState() == streamDone { return ErrIllegalHeaderWrite } s.hdrMu.Lock() if md.Len() > 0 { if s.header.Len() > 0 { s.header = metadata.Join(s.header, md) } else { s.header = md } } if err := t.writeHead...
go
func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error { if s.updateHeaderSent() || s.getState() == streamDone { return ErrIllegalHeaderWrite } s.hdrMu.Lock() if md.Len() > 0 { if s.header.Len() > 0 { s.header = metadata.Join(s.header, md) } else { s.header = md } } if err := t.writeHead...
[ "func", "(", "t", "*", "http2Server", ")", "WriteHeader", "(", "s", "*", "Stream", ",", "md", "metadata", ".", "MD", ")", "error", "{", "if", "s", ".", "updateHeaderSent", "(", ")", "||", "s", ".", "getState", "(", ")", "==", "streamDone", "{", "re...
// WriteHeader sends the header metedata md back to the client.
[ "WriteHeader", "sends", "the", "header", "metedata", "md", "back", "to", "the", "client", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L740-L758
127,088
grpc/grpc-go
internal/transport/http2_server.go
deleteStream
func (t *http2Server) deleteStream(s *Stream, eosReceived bool) (oldState streamState) { oldState = s.swapState(streamDone) if oldState == streamDone { // If the stream was already done, return. return oldState } // In case stream sending and receiving are invoked in separate // goroutines (e.g., bi-direction...
go
func (t *http2Server) deleteStream(s *Stream, eosReceived bool) (oldState streamState) { oldState = s.swapState(streamDone) if oldState == streamDone { // If the stream was already done, return. return oldState } // In case stream sending and receiving are invoked in separate // goroutines (e.g., bi-direction...
[ "func", "(", "t", "*", "http2Server", ")", "deleteStream", "(", "s", "*", "Stream", ",", "eosReceived", "bool", ")", "(", "oldState", "streamState", ")", "{", "oldState", "=", "s", ".", "swapState", "(", "streamDone", ")", "\n", "if", "oldState", "==", ...
// deleteStream deletes the stream s from transport's active streams.
[ "deleteStream", "deletes", "the", "stream", "s", "from", "transport", "s", "active", "streams", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L1022-L1052
127,089
grpc/grpc-go
internal/transport/http2_server.go
finishStream
func (t *http2Server) finishStream(s *Stream, rst bool, rstCode http2.ErrCode, hdr *headerFrame, eosReceived bool) { oldState := t.deleteStream(s, eosReceived) // If the stream is already closed, then don't put trailing header to controlbuf. if oldState == streamDone { return } hdr.cleanup = &cleanupStream{ s...
go
func (t *http2Server) finishStream(s *Stream, rst bool, rstCode http2.ErrCode, hdr *headerFrame, eosReceived bool) { oldState := t.deleteStream(s, eosReceived) // If the stream is already closed, then don't put trailing header to controlbuf. if oldState == streamDone { return } hdr.cleanup = &cleanupStream{ s...
[ "func", "(", "t", "*", "http2Server", ")", "finishStream", "(", "s", "*", "Stream", ",", "rst", "bool", ",", "rstCode", "http2", ".", "ErrCode", ",", "hdr", "*", "headerFrame", ",", "eosReceived", "bool", ")", "{", "oldState", ":=", "t", ".", "deleteSt...
// finishStream closes the stream and puts the trailing headerFrame into controlbuf.
[ "finishStream", "closes", "the", "stream", "and", "puts", "the", "trailing", "headerFrame", "into", "controlbuf", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L1055-L1069
127,090
grpc/grpc-go
internal/transport/http2_server.go
closeStream
func (t *http2Server) closeStream(s *Stream, rst bool, rstCode http2.ErrCode, eosReceived bool) { t.deleteStream(s, eosReceived) t.controlBuf.put(&cleanupStream{ streamID: s.id, rst: rst, rstCode: rstCode, onWrite: func() {}, }) }
go
func (t *http2Server) closeStream(s *Stream, rst bool, rstCode http2.ErrCode, eosReceived bool) { t.deleteStream(s, eosReceived) t.controlBuf.put(&cleanupStream{ streamID: s.id, rst: rst, rstCode: rstCode, onWrite: func() {}, }) }
[ "func", "(", "t", "*", "http2Server", ")", "closeStream", "(", "s", "*", "Stream", ",", "rst", "bool", ",", "rstCode", "http2", ".", "ErrCode", ",", "eosReceived", "bool", ")", "{", "t", ".", "deleteStream", "(", "s", ",", "eosReceived", ")", "\n", "...
// closeStream clears the footprint of a stream when the stream is not needed any more.
[ "closeStream", "clears", "the", "footprint", "of", "a", "stream", "when", "the", "stream", "is", "not", "needed", "any", "more", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L1072-L1080
127,091
grpc/grpc-go
internal/transport/http2_server.go
outgoingGoAwayHandler
func (t *http2Server) outgoingGoAwayHandler(g *goAway) (bool, error) { t.mu.Lock() if t.state == closing { // TODO(mmukhi): This seems unnecessary. t.mu.Unlock() // The transport is closing. return false, ErrConnClosing } sid := t.maxStreamID if !g.headsUp { // Stop accepting more streams now. t.state = ...
go
func (t *http2Server) outgoingGoAwayHandler(g *goAway) (bool, error) { t.mu.Lock() if t.state == closing { // TODO(mmukhi): This seems unnecessary. t.mu.Unlock() // The transport is closing. return false, ErrConnClosing } sid := t.maxStreamID if !g.headsUp { // Stop accepting more streams now. t.state = ...
[ "func", "(", "t", "*", "http2Server", ")", "outgoingGoAwayHandler", "(", "g", "*", "goAway", ")", "(", "bool", ",", "error", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "t", ".", "state", "==", "closing", "{", "// TODO(mmukhi): This ...
// Handles outgoing GoAway and returns true if loopy needs to put itself // in draining mode.
[ "Handles", "outgoing", "GoAway", "and", "returns", "true", "if", "loopy", "needs", "to", "put", "itself", "in", "draining", "mode", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/internal/transport/http2_server.go#L1104-L1155
127,092
grpc/grpc-go
balancer/grpclb/grpclb.go
regeneratePicker
func (lb *lbBalancer) regeneratePicker(resetDrop bool) { if lb.state == connectivity.TransientFailure { lb.picker = &errPicker{err: balancer.ErrTransientFailure} return } if lb.state == connectivity.Connecting { lb.picker = &errPicker{err: balancer.ErrNoSubConnAvailable} return } var readySCs []balancer....
go
func (lb *lbBalancer) regeneratePicker(resetDrop bool) { if lb.state == connectivity.TransientFailure { lb.picker = &errPicker{err: balancer.ErrTransientFailure} return } if lb.state == connectivity.Connecting { lb.picker = &errPicker{err: balancer.ErrNoSubConnAvailable} return } var readySCs []balancer....
[ "func", "(", "lb", "*", "lbBalancer", ")", "regeneratePicker", "(", "resetDrop", "bool", ")", "{", "if", "lb", ".", "state", "==", "connectivity", ".", "TransientFailure", "{", "lb", ".", "picker", "=", "&", "errPicker", "{", "err", ":", "balancer", ".",...
// regeneratePicker takes a snapshot of the balancer, and generates a picker from // it. The picker // - always returns ErrTransientFailure if the balancer is in TransientFailure, // - does two layer roundrobin pick otherwise. // Caller must hold lb.mu.
[ "regeneratePicker", "takes", "a", "snapshot", "of", "the", "balancer", "and", "generates", "a", "picker", "from", "it", ".", "The", "picker", "-", "always", "returns", "ErrTransientFailure", "if", "the", "balancer", "is", "in", "TransientFailure", "-", "does", ...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/grpclb/grpclb.go#L251-L302
127,093
grpc/grpc-go
balancer/grpclb/grpclb.go
updateStateAndPicker
func (lb *lbBalancer) updateStateAndPicker(forceRegeneratePicker bool, resetDrop bool) { oldAggrState := lb.state lb.state = lb.aggregateSubConnStates() // Regenerate picker when one of the following happens: // - caller wants to regenerate // - the aggregated state changed if forceRegeneratePicker || (lb.state...
go
func (lb *lbBalancer) updateStateAndPicker(forceRegeneratePicker bool, resetDrop bool) { oldAggrState := lb.state lb.state = lb.aggregateSubConnStates() // Regenerate picker when one of the following happens: // - caller wants to regenerate // - the aggregated state changed if forceRegeneratePicker || (lb.state...
[ "func", "(", "lb", "*", "lbBalancer", ")", "updateStateAndPicker", "(", "forceRegeneratePicker", "bool", ",", "resetDrop", "bool", ")", "{", "oldAggrState", ":=", "lb", ".", "state", "\n", "lb", ".", "state", "=", "lb", ".", "aggregateSubConnStates", "(", ")...
// updateStateAndPicker re-calculate the aggregated state, and regenerate picker // if overall state is changed. // // If forceRegeneratePicker is true, picker will be regenerated.
[ "updateStateAndPicker", "re", "-", "calculate", "the", "aggregated", "state", "and", "regenerate", "picker", "if", "overall", "state", "is", "changed", ".", "If", "forceRegeneratePicker", "is", "true", "picker", "will", "be", "regenerated", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/balancer/grpclb/grpclb.go#L379-L390
127,094
grpc/grpc-go
reflection/serverreflection.go
Register
func Register(s *grpc.Server) { rpb.RegisterServerReflectionServer(s, &serverReflectionServer{ s: s, }) }
go
func Register(s *grpc.Server) { rpb.RegisterServerReflectionServer(s, &serverReflectionServer{ s: s, }) }
[ "func", "Register", "(", "s", "*", "grpc", ".", "Server", ")", "{", "rpb", ".", "RegisterServerReflectionServer", "(", "s", ",", "&", "serverReflectionServer", "{", "s", ":", "s", ",", "}", ")", "\n", "}" ]
// Register registers the server reflection service on the given gRPC server.
[ "Register", "registers", "the", "server", "reflection", "service", "on", "the", "given", "gRPC", "server", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L68-L72
127,095
grpc/grpc-go
reflection/serverreflection.go
fileDescForType
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) { m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) } enc, _ := m.Descriptor() return decodeFileDesc(enc) }
go
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) { m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) } enc, _ := m.Descriptor() return decodeFileDesc(enc) }
[ "func", "(", "s", "*", "serverReflectionServer", ")", "fileDescForType", "(", "st", "reflect", ".", "Type", ")", "(", "*", "dpb", ".", "FileDescriptorProto", ",", "error", ")", "{", "m", ",", "ok", ":=", "reflect", ".", "Zero", "(", "reflect", ".", "Pt...
// fileDescForType gets the file descriptor for the given type. // The given type should be a proto message.
[ "fileDescForType", "gets", "the", "file", "descriptor", "for", "the", "given", "type", ".", "The", "given", "type", "should", "be", "a", "proto", "message", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L190-L198
127,096
grpc/grpc-go
reflection/serverreflection.go
decodeFileDesc
func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { raw, err := decompress(enc) if err != nil { return nil, fmt.Errorf("failed to decompress enc: %v", err) } fd := new(dpb.FileDescriptorProto) if err := proto.Unmarshal(raw, fd); err != nil { return nil, fmt.Errorf("bad descriptor: %v", err) }...
go
func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { raw, err := decompress(enc) if err != nil { return nil, fmt.Errorf("failed to decompress enc: %v", err) } fd := new(dpb.FileDescriptorProto) if err := proto.Unmarshal(raw, fd); err != nil { return nil, fmt.Errorf("bad descriptor: %v", err) }...
[ "func", "decodeFileDesc", "(", "enc", "[", "]", "byte", ")", "(", "*", "dpb", ".", "FileDescriptorProto", ",", "error", ")", "{", "raw", ",", "err", ":=", "decompress", "(", "enc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fm...
// decodeFileDesc does decompression and unmarshalling on the given // file descriptor byte slice.
[ "decodeFileDesc", "does", "decompression", "and", "unmarshalling", "on", "the", "given", "file", "descriptor", "byte", "slice", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L202-L213
127,097
grpc/grpc-go
reflection/serverreflection.go
decompress
func decompress(b []byte) ([]byte, error) { r, err := gzip.NewReader(bytes.NewReader(b)) if err != nil { return nil, fmt.Errorf("bad gzipped descriptor: %v", err) } out, err := ioutil.ReadAll(r) if err != nil { return nil, fmt.Errorf("bad gzipped descriptor: %v", err) } return out, nil }
go
func decompress(b []byte) ([]byte, error) { r, err := gzip.NewReader(bytes.NewReader(b)) if err != nil { return nil, fmt.Errorf("bad gzipped descriptor: %v", err) } out, err := ioutil.ReadAll(r) if err != nil { return nil, fmt.Errorf("bad gzipped descriptor: %v", err) } return out, nil }
[ "func", "decompress", "(", "b", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "r", ",", "err", ":=", "gzip", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "b", ")", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// decompress does gzip decompression.
[ "decompress", "does", "gzip", "decompression", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L216-L226
127,098
grpc/grpc-go
reflection/serverreflection.go
fileDescEncodingByFilename
func (s *serverReflectionServer) fileDescEncodingByFilename(name string) ([]byte, error) { enc := proto.FileDescriptor(name) if enc == nil { return nil, fmt.Errorf("unknown file: %v", name) } fd, err := decodeFileDesc(enc) if err != nil { return nil, err } return proto.Marshal(fd) }
go
func (s *serverReflectionServer) fileDescEncodingByFilename(name string) ([]byte, error) { enc := proto.FileDescriptor(name) if enc == nil { return nil, fmt.Errorf("unknown file: %v", name) } fd, err := decodeFileDesc(enc) if err != nil { return nil, err } return proto.Marshal(fd) }
[ "func", "(", "s", "*", "serverReflectionServer", ")", "fileDescEncodingByFilename", "(", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "enc", ":=", "proto", ".", "FileDescriptor", "(", "name", ")", "\n", "if", "enc", "==", "nil", ...
// fileDescEncodingByFilename finds the file descriptor for given filename, // does marshalling on it and returns the marshalled result.
[ "fileDescEncodingByFilename", "finds", "the", "file", "descriptor", "for", "given", "filename", "does", "marshalling", "on", "it", "and", "returns", "the", "marshalled", "result", "." ]
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L275-L285
127,099
grpc/grpc-go
reflection/serverreflection.go
parseMetadata
func parseMetadata(meta interface{}) ([]byte, bool) { // Check if meta is the file name. if fileNameForMeta, ok := meta.(string); ok { return proto.FileDescriptor(fileNameForMeta), true } // Check if meta is the byte slice. if enc, ok := meta.([]byte); ok { return enc, true } return nil, false }
go
func parseMetadata(meta interface{}) ([]byte, bool) { // Check if meta is the file name. if fileNameForMeta, ok := meta.(string); ok { return proto.FileDescriptor(fileNameForMeta), true } // Check if meta is the byte slice. if enc, ok := meta.([]byte); ok { return enc, true } return nil, false }
[ "func", "parseMetadata", "(", "meta", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "bool", ")", "{", "// Check if meta is the file name.", "if", "fileNameForMeta", ",", "ok", ":=", "meta", ".", "(", "string", ")", ";", "ok", "{", "return", "pr...
// parseMetadata finds the file descriptor bytes specified meta. // For SupportPackageIsVersion4, m is the name of the proto file, we // call proto.FileDescriptor to get the byte slice. // For SupportPackageIsVersion3, m is a byte slice itself.
[ "parseMetadata", "finds", "the", "file", "descriptor", "bytes", "specified", "meta", ".", "For", "SupportPackageIsVersion4", "m", "is", "the", "name", "of", "the", "proto", "file", "we", "call", "proto", ".", "FileDescriptor", "to", "get", "the", "byte", "slic...
028242f87445bf2cc2807399d403cbbada8c0e85
https://github.com/grpc/grpc-go/blob/028242f87445bf2cc2807399d403cbbada8c0e85/reflection/serverreflection.go#L291-L303