Skip to content

Commit

Permalink
Chore: change method name
Browse files Browse the repository at this point in the history
  • Loading branch information
asheswook committed Sep 3, 2024
1 parent 7d3176a commit b030298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions example/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ var channelRegistry = messageRelayer.NewChannelRegistry[ExampleTxContext]()

func init() {
var err error
err = channelRegistry.RegisterChannel(ExampleSuccessChannel)
err = channelRegistry.RegisterChannel(ExampleFailureChannel)
err = channelRegistry.RegisterChannel(ExampleCommandChannel)
err = channelRegistry.RegisterChannel(AlwaysFailCommandChannel)
err = channelRegistry.Register(ExampleSuccessChannel)
err = channelRegistry.Register(ExampleFailureChannel)
err = channelRegistry.Register(ExampleCommandChannel)
err = channelRegistry.Register(AlwaysFailCommandChannel)

if err != nil {
panic(err)
Expand Down
7 changes: 3 additions & 4 deletions messageRelayer/channel.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package messageRelayer

import (
"errors"
"github.com/violetpay-org/go-saga"
"sync"
)

type ChannelRegistry[Tx saga.TxContext] interface {
RegisterChannel(channel Channel[Tx]) error
Register(channel Channel[Tx]) error

// Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range(func(name saga.ChannelName, channel Channel[Tx]) bool)
Expand Down Expand Up @@ -56,9 +55,9 @@ func NewChannelRegistry[Tx saga.TxContext]() ChannelRegistry[Tx] {
return &channelRegistry[Tx]{}
}

func (r *channelRegistry[Tx]) RegisterChannel(channel Channel[Tx]) error {
func (r *channelRegistry[Tx]) Register(channel Channel[Tx]) error {
if _, ok := r.channels.Load(channel.Name()); ok {
return errors.New("channel already exists")
return saga.ErrChannelAlreadyRegistered
}
r.channels.Store(channel.Name(), channel)
return nil
Expand Down

0 comments on commit b030298

Please sign in to comment.