Skip to content

vectorhacker/mediator

Repository files navigation

mediator

Simple mediator implementation for Go

Go Report Card Coverage Go

Example

type MessageHandler struct{}

type Message struct {
    Foo string
}

type Response struct {
    Result string
}

func (h MessageHandler) Handle(ctx context.Context, msg *Message) (Response, error) {
    return Response{ msg.Foo + " bar "}, nil
}


m, err := mediator.New(mediator.WithHandler(&MessageHandler{})) 

r, err := m.Send(context.Background(), &Message{ "foo" })
// ...

About

Simple mediator implementation for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages