Skip to content

Commit

Permalink
Merge pull request #17 from baibikov/tcp-routing
Browse files Browse the repository at this point in the history
feat(routing): use interface type into comparable
  • Loading branch information
baibikov authored Sep 19, 2022
2 parents 2b62b47 + 424a563 commit ca0d607
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/tcp/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (h *handler) distribute() error {

logrus.Debugf("processing message by type - %d", typ)

route := routing.New(map[comparable]routing.HandlerFunc{
route := routing.New(map[interface{}]routing.HandlerFunc{
setMessageType: h.set,
getMessageType: h.get,
commitMessageType: h.commit,
Expand Down
6 changes: 3 additions & 3 deletions pkg/routing/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import "github.com/pkg/errors"
type HandlerFunc func() error

type Routing struct {
handlers map[comparable]HandlerFunc
handlers map[interface{}]HandlerFunc
}

func New(handlers map[comparable]HandlerFunc) *Routing {
func New(handlers map[interface{}]HandlerFunc) *Routing {
return &Routing{
handlers: handlers,
}
}

func (r *Routing) Distribute(k comparable) error {
func (r *Routing) Distribute(k interface{}) error {
hh, ok := r.handlers[k]
if !ok {
return errors.Errorf("undefined key to distribute - %+v", k)
Expand Down

0 comments on commit ca0d607

Please sign in to comment.