diff --git a/LICENSE b/LICENSE index 1abc0a7..c8f2010 100644 --- a/LICENSE +++ b/LICENSE @@ -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). @@ -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 @@ -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. @@ -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. diff --git a/examples/concurrent_event_bus/main.go b/examples/concurrent_event_bus/main.go index cc7a171..cf09724 100644 --- a/examples/concurrent_event_bus/main.go +++ b/examples/concurrent_event_bus/main.go @@ -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") diff --git a/examples/events_bus/main.go b/examples/events_bus/main.go index c2e2683..556d199 100644 --- a/examples/events_bus/main.go +++ b/examples/events_bus/main.go @@ -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") diff --git a/pkg/bus/bus.go b/pkg/bus/bus.go index 3034c14..802e1b1 100644 --- a/pkg/bus/bus.go +++ b/pkg/bus/bus.go @@ -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 { @@ -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 diff --git a/pkg/bus/bus_test.go b/pkg/bus/bus_test.go index 62a7dd9..9e73ea6 100644 --- a/pkg/bus/bus_test.go +++ b/pkg/bus/bus_test.go @@ -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) }{ { diff --git a/pkg/bus/concurrent_bus.go b/pkg/bus/concurrent_bus.go index 25c2423..58c4720 100644 --- a/pkg/bus/concurrent_bus.go +++ b/pkg/bus/concurrent_bus.go @@ -6,7 +6,7 @@ import ( ) type Response struct { - Response any + Response interface{} Err error } diff --git a/pkg/bus/fixtures_test.go b/pkg/bus/fixtures_test.go index 93a4318..2a57e94 100644 --- a/pkg/bus/fixtures_test.go +++ b/pkg/bus/fixtures_test.go @@ -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(): @@ -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 diff --git a/pkg/cqrs/cqrs.go b/pkg/cqrs/cqrs.go index 65f2bb4..05c225e 100644 --- a/pkg/cqrs/cqrs.go +++ b/pkg/cqrs/cqrs.go @@ -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 @@ -62,7 +62,7 @@ type Query interface { } // QueryResult is self-described -type QueryResult any +type QueryResult interface{} // QueryHandler handles a query type QueryHandler interface { diff --git a/pkg/cqrs/mock_logger_test.go b/pkg/cqrs/mock_logger_test.go index 4a4456e..74b63eb 100644 --- a/pkg/cqrs/mock_logger_test.go +++ b/pkg/cqrs/mock_logger_test.go @@ -18,7 +18,7 @@ var _ cqrs.Logger = &LoggerMock{} // // // make and configure a mocked cqrs.Logger // mockedLogger := &LoggerMock{ -// PrintfFunc: func(format string, v ...any) { +// PrintfFunc: func(format string, v ...interface{}) { // panic("mock out the Printf method") // }, // } @@ -29,7 +29,7 @@ var _ cqrs.Logger = &LoggerMock{} // } type LoggerMock struct { // PrintfFunc mocks the Printf method. - PrintfFunc func(format string, v ...any) + PrintfFunc func(format string, v ...interface{}) // calls tracks calls to the methods. calls struct { @@ -38,17 +38,17 @@ type LoggerMock struct { // Format is the format argument value. Format string // V is the v argument value. - V []any + V []interface{} } } lockPrintf sync.RWMutex } // Printf calls PrintfFunc. -func (mock *LoggerMock) Printf(format string, v ...any) { +func (mock *LoggerMock) Printf(format string, v ...interface{}) { callInfo := struct { Format string - V []any + V []interface{} }{ Format: format, V: v, @@ -68,11 +68,11 @@ func (mock *LoggerMock) Printf(format string, v ...any) { // len(mockedLogger.PrintfCalls()) func (mock *LoggerMock) PrintfCalls() []struct { Format string - V []any + V []interface{} } { var calls []struct { Format string - V []any + V []interface{} } mock.lockPrintf.RLock() calls = mock.calls.Printf diff --git a/pkg/events/event.go b/pkg/events/event.go index e48eb76..f84b53e 100644 --- a/pkg/events/event.go +++ b/pkg/events/event.go @@ -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, @@ -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 } diff --git a/pkg/helpers/helpers.go b/pkg/helpers/helpers.go index 66c6166..67f2f35 100644 --- a/pkg/helpers/helpers.go +++ b/pkg/helpers/helpers.go @@ -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") @@ -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")