Skip to content

Commit 9a21f8f

Browse files
[PRIV-158] Add RemoveHandler (#1514)
1 parent 4669923 commit 9a21f8f

File tree

6 files changed

+185
-33
lines changed

6 files changed

+185
-33
lines changed

pkg/loop/internal/core/services/gateway/gateway_connector.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ func (c GatewayConnectorClient) AddHandler(ctx context.Context, methods []string
4747
return nil
4848
}
4949

50+
func (c GatewayConnectorClient) RemoveHandler(ctx context.Context, methods []string) error {
51+
_, err := c.grpc.RemoveHandler(ctx, &pb.RemoveHandlerRequest{
52+
Methods: methods,
53+
})
54+
return err
55+
}
56+
5057
func (c GatewayConnectorClient) GatewayIDs(ctx context.Context) ([]string, error) {
5158
resp, err := c.grpc.GatewayIDs(ctx, &emptypb.Empty{})
5259
if err != nil {

pkg/loop/internal/pb/gatewayconnector/gateway_connector.pb.go

Lines changed: 75 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/loop/internal/pb/gatewayconnector/gateway_connector.proto

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@ message AddHandlerRequest {
3232
uint32 handler_id = 2;
3333
}
3434

35+
message RemoveHandlerRequest {
36+
repeated string methods = 1;
37+
}
38+
3539
service GatewayConnector {
3640
rpc AddHandler(AddHandlerRequest) returns (google.protobuf.Empty);
41+
rpc RemoveHandler(RemoveHandlerRequest) returns (google.protobuf.Empty);
3742
rpc SendToGateway(SendMessageRequest) returns (google.protobuf.Empty);
3843
rpc SignMessage(SignMessageRequest) returns (SignMessageReply);
3944
rpc GatewayIDs(google.protobuf.Empty) returns (GatewayIDsReply);
4045
rpc DonID(google.protobuf.Empty) returns (DonIDReply);
4146
rpc AwaitConnection(GatewayIDRequest) returns (google.protobuf.Empty);
42-
}
47+
}

pkg/loop/internal/pb/gatewayconnector/gateway_connector_grpc.pb.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/types/core/gateway_connector.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package core
33
import (
44
"context"
55
"encoding/json"
6-
"fmt"
6+
"errors"
77

88
jsonrpc "github.com/smartcontractkit/chainlink-common/pkg/jsonrpc2"
99
)
@@ -12,6 +12,7 @@ import (
1212
type GatewayConnector interface {
1313
// AddHandler adds a handler to the GatewayConnector
1414
AddHandler(ctx context.Context, methods []string, handler GatewayConnectorHandler) error
15+
RemoveHandler(ctx context.Context, methods []string) error
1516
// SendToGateway takes a signed message as argument and sends it to the specified gateway
1617
SendToGateway(ctx context.Context, gatewayID string, resp *jsonrpc.Response[json.RawMessage]) error
1718
// Sign the given message and return signature
@@ -37,25 +38,29 @@ var _ GatewayConnector = (*UnimplementedGatewayConnector)(nil)
3738
type UnimplementedGatewayConnector struct{}
3839

3940
func (u *UnimplementedGatewayConnector) AddHandler(ctx context.Context, methods []string, handler GatewayConnectorHandler) error {
40-
return fmt.Errorf("not implemented")
41+
return errors.New("not implemented")
42+
}
43+
44+
func (u *UnimplementedGatewayConnector) RemoveHandler(ctx context.Context, methods []string) error {
45+
return errors.New("not implemented")
4146
}
4247

4348
func (u *UnimplementedGatewayConnector) SendToGateway(ctx context.Context, gatewayID string, resp *jsonrpc.Response[json.RawMessage]) error {
44-
return fmt.Errorf("not implemented")
49+
return errors.New("not implemented")
4550
}
4651

4752
func (u *UnimplementedGatewayConnector) SignMessage(ctx context.Context, msg []byte) ([]byte, error) {
48-
return nil, fmt.Errorf("not implemented")
53+
return nil, errors.New("not implemented")
4954
}
5055

5156
func (u *UnimplementedGatewayConnector) GatewayIDs(ctx context.Context) ([]string, error) {
52-
return nil, fmt.Errorf("not implemented")
57+
return nil, errors.New("not implemented")
5358
}
5459

5560
func (u *UnimplementedGatewayConnector) DonID(ctx context.Context) (string, error) {
56-
return "", fmt.Errorf("not implemented")
61+
return "", errors.New("not implemented")
5762
}
5863

5964
func (u *UnimplementedGatewayConnector) AwaitConnection(ctx context.Context, gatewayID string) error {
60-
return fmt.Errorf("not implemented")
65+
return errors.New("not implemented")
6166
}

pkg/types/core/mocks/gateway_connector.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)