Skip to content

Commit

Permalink
perf: remove provider transaction event subscription (#622)
Browse files Browse the repository at this point in the history
* Deactivated events.Publish subscribes to the tendermint event bus
and re-published events to the rest of the provider/
modules.

fixes #606

Signed-off-by: Josh Roppo <[email protected]>
  • Loading branch information
AkashJosh authored May 29, 2020
1 parent f0a7096 commit 0bf96e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
13 changes: 2 additions & 11 deletions events/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ import (
"golang.org/x/sync/errgroup"
)

// Publish publishes events along tm buses to clients
// Publish events using tm buses to clients. Waits on context
// shutdown signals to exit.
func Publish(ctx context.Context, tmbus tmclient.EventsClient, name string, bus pubsub.Bus) error {

const (
queuesz = 100
)
var (
txname = name + "-tx"
blkname = name + "-blk"
)

txch, err := tmbus.Subscribe(ctx, txname, txQuery().String(), queuesz)
if err != nil {
return err
}
defer tmbus.UnsubscribeAll(ctx, txname)

blkch, err := tmbus.Subscribe(ctx, blkname, blkQuery().String(), queuesz)
if err != nil {
return err
Expand All @@ -40,9 +34,6 @@ func Publish(ctx context.Context, tmbus tmclient.EventsClient, name string, bus

g, ctx := errgroup.WithContext(ctx)

g.Go(func() error {
return publishEvents(ctx, txch, bus)
})
g.Go(func() error {
return publishEvents(ctx, blkch, bus)
})
Expand Down
5 changes: 0 additions & 5 deletions events/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
)

func txQuery() pubsub.Query {
return tmquery.MustParse(
fmt.Sprintf("%s='%s'", tmtypes.EventTypeKey, tmtypes.EventTx))
}

func blkQuery() pubsub.Query {
return tmquery.MustParse(
fmt.Sprintf("%s='%s'", tmtypes.EventTypeKey, tmtypes.EventNewBlockHeader))
Expand Down
3 changes: 3 additions & 0 deletions provider/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func runCmd(cdc *codec.Codec) *cobra.Command {
return cmd
}

// doRunCmd initializes all of the Provider functionality, hangs, and awaits shutdown signals.
func doRunCmd(ctx context.Context, cdc *codec.Codec, cmd *cobra.Command, _ []string) error {
cctx := ccontext.NewCLIContext().WithCodec(cdc)

Expand Down Expand Up @@ -81,6 +82,7 @@ func doRunCmd(ctx context.Context, cdc *codec.Codec, cmd *cobra.Command, _ []str
return err
}

// k8s client creation
cclient, err := createClusterClient(log, cmd, pinfo.HostURI)
if err != nil {
return err
Expand Down Expand Up @@ -117,6 +119,7 @@ func doRunCmd(ctx context.Context, cdc *codec.Codec, cmd *cobra.Command, _ []str

func createClusterClient(log log.Logger, cmd *cobra.Command, host string) (cluster.Client, error) {
if val, _ := cmd.Flags().GetBool(flagClusterK8s); !val {
// Condition that there is no Kubernetes API to work with.
return cluster.NullClient(), nil
}
ns, err := cmd.Flags().GetString(flagK8sManifestNS)
Expand Down

0 comments on commit 0bf96e2

Please sign in to comment.