You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, i used following code to support TCP and Unix sockets:
// SchemaDialer supports an optional protocol prefix
// (like "tcp://" or "unix://"). TCP is the default.
func SchemaDialer(addr string, timeout time.Duration) (net.Conn, error) {
proto, addr := SplitSchemaAddr(addr)
return net.DialTimeout(proto, addr, timeout)
}
// SplitSchemaAddr parses an address with an optional protocol prefix
// (like "tcp://" or "unix://"). TCP is the default.
func SplitSchemaAddr(addr string) (string, string) {
parts := reSchema.FindStringSubmatch(addr)
proto, addr := parts[1], parts[2]
if proto == "" {
proto = "tcp"
}
return proto, addr
}
var reSchema = regexp.MustCompile("^(?:([a-z0-9]+)://)?(.*)$")
The usage itself looked like grpc.Dial(addr, grpc.WithDialer(SchemaDialer)) and worked fine with previous GRPC versions. The value of addr is for example unix:///run/example.sock and the old GRPC behavior was that the value of addr gets passed to the dialer unmodified.
After a recent update to 1.9.2 the behavior has changed significantly. The address gets parsed before, the schema and the first slash gets removed and "run/example.sock" (note the relative path and missing schema) is passed to my SchemaDialer(). This all happens in the line cc.parsedTarget = parseTarget(cc.target) within grpc.DialContext() and is not configureable.
Without access to the original address, the addr parameter for the dialer is completely useless to me. I can probably ignore it and use a value from a closure, but I guess that's not the intended way.
Any help is appreciated! Many thanks!
The text was updated successfully, but these errors were encountered:
We will support the unix scheme out of the box when #1741 is fixed, at which point you would use unix:////run/example.sock (note the four slashes up front: two after schema, one after authority, and one as the beginning of the endpoint name) or dns:///hostname.com or dns:///<numeric IP> (dns is installed by default).
Sorry for the change of behavior. The previous implementation did not follow the grpc spec, which was preventing us from supporting other features that we needed. Let me know if you have any other questions.
Previously, i used following code to support TCP and Unix sockets:
The usage itself looked like
grpc.Dial(addr, grpc.WithDialer(SchemaDialer))
and worked fine with previous GRPC versions. The value of addr is for exampleunix:///run/example.sock
and the old GRPC behavior was that the value of addr gets passed to the dialer unmodified.After a recent update to 1.9.2 the behavior has changed significantly. The address gets parsed before, the schema and the first slash gets removed and "run/example.sock" (note the relative path and missing schema) is passed to my
SchemaDialer()
. This all happens in the linecc.parsedTarget = parseTarget(cc.target)
withingrpc.DialContext()
and is not configureable.Without access to the original address, the addr parameter for the dialer is completely useless to me. I can probably ignore it and use a value from a closure, but I guess that's not the intended way.
Any help is appreciated! Many thanks!
The text was updated successfully, but these errors were encountered: