@@ -19,29 +19,30 @@ import (
1919
2020// Hashring is a wrapper around the consistent hash implementation that
2121type Hashring struct {
22- checker invoke.Check
23- gossip gossip.IGossip
24- consistent hash.Consistent
25- localNodeAddress string
26- l * logger.Logger
22+ checker invoke.Check
23+ gossip gossip.IGossip
24+ consistent hash.Consistent
25+ localNodeAddress string
26+ connectionOptions []grpc.DialOption
27+ l * logger.Logger
2728}
2829
2930// NewCheckEngineWithHashring creates a new instance of EngineKeyManager by initializing an EngineKeys
3031// struct with the provided cache.Cache instance.
31- func NewCheckEngineWithHashring (checker invoke.Check , consistent * hash.ConsistentHash , g * gossip.Gossip , port string , l * logger.Logger ) (invoke.Check , error ) {
32+ func NewCheckEngineWithHashring (checker invoke.Check , consistent * hash.ConsistentHash , g * gossip.Gossip , port string , l * logger.Logger , options ... grpc. DialOption ) (invoke.Check , error ) {
3233 // Return a new instance of EngineKeys with the provided cache
33-
3434 ip , err := gossip .ExternalIP ()
3535 if err != nil {
3636 return nil , err
3737 }
3838
3939 return & Hashring {
40- checker : checker ,
41- localNodeAddress : ip + ":" + port ,
42- gossip : g ,
43- consistent : consistent ,
44- l : l ,
40+ checker : checker ,
41+ localNodeAddress : ip + ":" + port ,
42+ gossip : g ,
43+ consistent : consistent ,
44+ connectionOptions : options ,
45+ l : l ,
4546 }, nil
4647}
4748
@@ -96,7 +97,7 @@ func (c *Hashring) Check(ctx context.Context, request *base.PermissionCheckReque
9697// forwardRequestGetToNode forwards a request to the responsible node
9798func (c * Hashring ) forwardRequestToNode (ctx context.Context , node string , request * base.PermissionCheckRequest ) (* base.PermissionCheckResponse , error ) {
9899 // Set up a connection to the server.
99- conn , err := grpc .Dial ( node , grpc . WithInsecure (), grpc . WithBlock () )
100+ conn , err := grpc .DialContext ( ctx , node , c . connectionOptions ... )
100101 if err != nil {
101102 log .Fatalf ("did not connect: %v" , err )
102103 }
0 commit comments