Skip to content

Commit fa108fe

Browse files
committed
*: gofumpt
1 parent 6af4184 commit fa108fe

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

integration-test/integration_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func healthCheck(attempts int) error {
5353

5454
// HTTP POST: /translation/do-translate.
5555
func TestHTTPCheckRequest(t *testing.T) {
56-
5756
body := `{
5857
"schema": "entity user {} \n\nentity account {\n // roles \n relation admin @user \n relation member @user \n relation parent_account @account\n\n action add_member = admin or parent_account.add_member\n action delete_member = admin\n\n}"
5958
}`
@@ -90,5 +89,4 @@ func TestHTTPCheckRequest(t *testing.T) {
9089
Expect().Status().Equal(http.StatusOK),
9190
Expect().Body().JSON().JQ(".can").Equal("RESULT_DENIED"),
9291
)
93-
9492
}

internal/config/config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ type (
2626

2727
// Server contains the configurations for both HTTP and gRPC servers.
2828
Server struct {
29-
Address string `mapstructure:"address"` // Address for the server
30-
HTTP `mapstructure:"http"` // HTTP server configuration
31-
GRPC `mapstructure:"grpc"` // gRPC server configuration
29+
Address string `mapstructure:"address"` // Address for the server
30+
HTTP `mapstructure:"http"` // HTTP server configuration
31+
GRPC `mapstructure:"grpc"` // gRPC server configuration
3232
}
3333

3434
// HTTP contains configuration for the HTTP server.
@@ -301,11 +301,9 @@ func DefaultConfig() *Config {
301301
}
302302

303303
func isYAML(file string) error {
304-
305304
ext := filepath.Ext(file)
306305
if ext != "yaml" {
307306
return errors.New("file is not yaml")
308307
}
309308
return nil
310-
311309
}

internal/engines/consistent/hashring.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,30 @@ import (
1919

2020
// Hashring is a wrapper around the consistent hash implementation that
2121
type 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
9798
func (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

Comments
 (0)