Skip to content

Commit

Permalink
chore: self review
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Feb 7, 2024
1 parent 64376a5 commit f547e7b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
30 changes: 6 additions & 24 deletions abci/client/routed_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ type Routing map[RequestType][]Client
//
// Example:
//
// "Info:socket:unix:///tmp/socket.1,Info:socket:unix:///tmp/socket.2,CheckTx:socket:unix:///tmp/socket.1,Query:socket:unix:///tmp/socket.2,*:socket:unix:///tmp/socket.3"
// ```
//
// "Info:socket:unix:///tmp/socket.1,Info:socket:unix:///tmp/socket.2,CheckTx:socket:unix:///tmp/socket.1,*:socket:unix:///tmp/socket.3"
//
// ```
//
// # Arguments
// - `logger` - The logger to use for the client.
// - `addr` - comma-separated list of routing rules, consisting of request type and client address separated with colon.
// - `addr` - comma-separated list of routing rules, consisting of request type, transport name and client address separated with colon.
// Special request type "*" is used for default client.
func NewRoutedClientWithAddr(logger log.Logger, addr string, mustConnect bool) (Client, error) {
// Split the routing rules
Expand Down Expand Up @@ -136,30 +140,8 @@ func (cli *routedClient) OnStart(ctx context.Context) error {
}

func (cli *routedClient) OnStop() {
// FIXME: Stop all underlying clients
}

// // getClient returns the client for the caller function
// func (cli *routedClient) getClient() (Client, error) {
// // Get the caller function name; it will be our request type
// pc, _, _, _ := runtime.Caller(1)
// funcObj := runtime.FuncForPC(pc)
// funcName := funcObj.Name()
// // remove package name
// funcName = funcName[strings.LastIndex(funcName, ".")+1:]

// client, ok := cli.routing[RequestType(funcName)]
// if !ok {
// if cli.defaultClient != nil {
// return *cli.defaultClient, nil
// }

// return nil, fmt.Errorf("no client for ABCI method %s", funcName)
// }

// return client, nil
// }

// delegate calls the given function on the appropriate client with the given
// arguments.
//
Expand Down
10 changes: 1 addition & 9 deletions abci/client/routed_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,12 @@ func TestRouting(t *testing.T) {
fmt.Sprintf(",PrepareProposal:socket:%s", consensusSocket) +
fmt.Sprintf(",*:socket:%s", defaultSocket)

logger.Info("configuring routed abci client with address", "addr", addr)
routedClient, err := abciclient.NewRoutedClientWithAddr(logger, addr, true)
assert.NoError(t, err)
err = routedClient.Start(ctx)
assert.NoError(t, err)

// routing := abciclient.Routing{
// abciclient.RequestType("CheckTx"): []abciclient.Client{queryApp},
// abciclient.RequestType("FinalizeBlock"): []abciclient.Client{queryApp, consensusApp},
// abciclient.RequestType("PrepareProposal"): []abciclient.Client{consensusApp},
// }

// routedClient, err := abciclient.NewRoutedClient(logger, defaultApp, routing)
assert.NoError(t, err)

// Test routing

// Info
Expand Down
2 changes: 1 addition & 1 deletion config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const defaultConfigTemplate = `# This is a TOML config file.
# or the name of an ABCI application compiled in with the Tendermint binary
# Example for routed multi-app setup:
# abci = "routed"
# proxy-app = "Info:socket:///tmp/socket.1,Info:socket:///tmp/socket.2,CheckTx:socket:///tmp/socket.1,*:socket:///tmp/socket.3"
# proxy-app = "Info:socket:unix:///tmp/socket.1,Info:socket:unix:///tmp/socket.2,CheckTx:socket:unix:///tmp/socket.1,*:socket:unix:///tmp/socket.3"
proxy-app = "{{ .BaseConfig.ProxyApp }}"
Expand Down

0 comments on commit f547e7b

Please sign in to comment.