Skip to content

Commit

Permalink
Disabled GRPC server
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Jan 28, 2025
1 parent 6bd4793 commit 700d9ae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "github.com/multiversx/mx-chain-sovereign-bridge-go/cert"

// ClientConfig holds all grpc client's config
type ClientConfig struct {
Enabled bool
GRPCHost string
GRPCPort string
CertificateCfg cert.FileCfg
Expand Down
29 changes: 29 additions & 0 deletions client/disabled/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package disabled

import (
"context"

"github.com/multiversx/mx-chain-core-go/data/sovereign"
)

type client struct{}

// NewClient creates a new instance of disabled client
func NewClient() *client {
return &client{}
}

// Send -
func (c *client) Send(_ context.Context, _ *sovereign.BridgeOperations) (*sovereign.BridgeOperationsResponse, error) {
return &sovereign.BridgeOperationsResponse{}, nil
}

// Close -
func (c *client) Close() error {
return nil
}

// IsInterfaceNil checks if the underlying pointer is nil
func (c *client) IsInterfaceNil() bool {
return c == nil
}
10 changes: 8 additions & 2 deletions client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (

"github.com/multiversx/mx-chain-core-go/data/sovereign"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-sovereign-bridge-go/cert"
"github.com/multiversx/mx-chain-sovereign-bridge-go/client/config"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/multiversx/mx-chain-sovereign-bridge-go/cert"
"github.com/multiversx/mx-chain-sovereign-bridge-go/client/config"
"github.com/multiversx/mx-chain-sovereign-bridge-go/client/disabled"
)

const (
Expand All @@ -20,6 +22,10 @@ var log = logger.GetOrCreate("client")

// CreateClient creates a grpc client with retries
func CreateClient(cfg *config.ClientConfig) (ClientHandler, error) {
if !cfg.Enabled {
return disabled.NewClient(), nil
}

dialTarget := fmt.Sprintf("%s:%s", cfg.GRPCHost, cfg.GRPCPort)
conn, err := connectWithRetries(dialTarget, cfg.CertificateCfg)
if err != nil {
Expand Down

0 comments on commit 700d9ae

Please sign in to comment.