Skip to content

Commit

Permalink
Replace 'any' by 'interface{}' for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
theskyinflames-macos authored and theskyinflames-macos committed Dec 12, 2022
1 parent 96b49d5 commit 4701eff
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ the above requirements apply either way.
8. Termination.

You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
provided under this License. any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
Expand Down Expand Up @@ -591,7 +591,7 @@ later version.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
OF any KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
Expand All @@ -600,12 +600,12 @@ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
WILL any COPYRIGHT HOLDER, OR any OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING any
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH any OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

Expand Down Expand Up @@ -640,7 +640,7 @@ the "copyright" line and a pointer to where the full notice is found.
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT any WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

Expand Down
2 changes: 1 addition & 1 deletion examples/concurrent_event_bus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func busHandlers(inChs []chan events.Event) []bus.Handler {
var busHnds []bus.Handler
for i := range inChs {
i := i
busHnds = append(busHnds, func(_ context.Context, d bus.Dispatchable) (any, error) {
busHnds = append(busHnds, func(_ context.Context, d bus.Dispatchable) (interface{}, error) {
e, ok := d.(events.Event)
if !ok {
return nil, errors.New("unexpected dispatchable")
Expand Down
2 changes: 1 addition & 1 deletion examples/events_bus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
},
}
eventsListener = events.NewListener(eventsChan, eventName, eventHandlers...)
busHandler bus.Handler = func(_ context.Context, d bus.Dispatchable) (any, error) {
busHandler bus.Handler = func(_ context.Context, d bus.Dispatchable) (interface{}, error) {
e, ok := d.(events.Event)
if !ok {
return nil, errors.New("unexpected dispatchable")
Expand Down
4 changes: 2 additions & 2 deletions pkg/bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Dispatchable interface {
}

// Handler handles a dispatchable from the bus
type Handler func(ctx context.Context, d Dispatchable) (any, error)
type Handler func(ctx context.Context, d Dispatchable) (interface{}, error)

// Bus is self-described
type Bus struct {
Expand All @@ -36,7 +36,7 @@ func (b Bus) Register(n string, h Handler) {
var ErrNotDispatchable = errors.New("not dispatchable")

// Dispatch dispatches a dispatchable item
func (b Bus) Dispatch(ctx context.Context, d Dispatchable) (any, error) {
func (b Bus) Dispatch(ctx context.Context, d Dispatchable) (interface{}, error) {
h, ok := b.h[d.Name()]
if !ok {
return nil, ErrNotDispatchable
Expand Down
2 changes: 1 addition & 1 deletion pkg/bus/bus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestBusDispatch(t *testing.T) {
handlerName string
handler bus.Handler
dispatchable bus.Dispatchable
expected any
expected interface{}
expectedErrFunc func(t *testing.T, err error)
}{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/bus/concurrent_bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Response struct {
Response any
Response interface{}
Err error
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/bus/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/theskyinflames/cqrs-eda/pkg/bus"
)

func handlerFixture(result any, err error) bus.Handler {
return func(_ context.Context, _ bus.Dispatchable) (any, error) {
func handlerFixture(result interface{}, err error) bus.Handler {
return func(_ context.Context, _ bus.Dispatchable) (interface{}, error) {
return result, err
}
}

func waitForCtxCancelledHandlerFixture(result any, err error) bus.Handler {
return func(ctx context.Context, _ bus.Dispatchable) (any, error) {
func waitForCtxCancelledHandlerFixture(result interface{}, err error) bus.Handler {
return func(ctx context.Context, _ bus.Dispatchable) (interface{}, error) {
for {
select {
case <-ctx.Done():
Expand All @@ -24,8 +24,8 @@ func waitForCtxCancelledHandlerFixture(result any, err error) bus.Handler {
}
}

func randomTimeHandlerFixture(result any, duration time.Duration, err error) bus.Handler {
return func(_ context.Context, d bus.Dispatchable) (any, error) {
func randomTimeHandlerFixture(result interface{}, duration time.Duration, err error) bus.Handler {
return func(_ context.Context, d bus.Dispatchable) (interface{}, error) {
// Simulate handler execution time
time.Sleep(duration)
return result, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/cqrs/cqrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// Logger is an interface
type Logger interface {
Printf(format string, v ...any)
Printf(format string, v ...interface{})
}

// Event is an event
Expand Down Expand Up @@ -62,7 +62,7 @@ type Query interface {
}

// QueryResult is self-described
type QueryResult any
type QueryResult interface{}

// QueryHandler handles a query
type QueryHandler interface {
Expand Down
14 changes: 7 additions & 7 deletions pkg/cqrs/mock_logger_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ type EventBasic struct {
ID uuid.UUID
aggregateID uuid.UUID
name string
body any
body interface{}
}

// NewEventBasic is a constructor
func NewEventBasic(aggregateID uuid.UUID, name string, body any) EventBasic {
func NewEventBasic(aggregateID uuid.UUID, name string, body interface{}) EventBasic {
return EventBasic{
ID: uuid.New(),
aggregateID: aggregateID,
Expand All @@ -31,6 +31,6 @@ func (e EventBasic) AggregateID() uuid.UUID {
}

// Body is a getter
func (e EventBasic) Body() any {
func (e EventBasic) Body() interface{} {
return e.body
}
4 changes: 2 additions & 2 deletions pkg/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func BusChHandler(ch cqrs.CommandHandler) bus.Handler {
return func(ctx context.Context, d bus.Dispatchable) (any, error) {
return func(ctx context.Context, d bus.Dispatchable) (interface{}, error) {
cmd, ok := d.(cqrs.Command)
if !ok {
return nil, errors.New("unexpected dispatchable")
Expand All @@ -19,7 +19,7 @@ func BusChHandler(ch cqrs.CommandHandler) bus.Handler {
}

func BusQhHandler(ch cqrs.QueryHandler) bus.Handler {
return func(ctx context.Context, d bus.Dispatchable) (any, error) {
return func(ctx context.Context, d bus.Dispatchable) (interface{}, error) {
cmd, ok := d.(cqrs.Query)
if !ok {
return nil, errors.New("unexpected dispatchable")
Expand Down

0 comments on commit 4701eff

Please sign in to comment.