From 9a0b20c0eb9ebe53416ee9c3660040c0b8b0bde8 Mon Sep 17 00:00:00 2001 From: Christian Carlsson Date: Fri, 20 Dec 2024 17:02:38 +0000 Subject: [PATCH] refact: pubsub: use postgres listen/notify (#268) --- database/migrations/022_events.up.sql | 13 + go.mod | 3 +- go.sum | 2 + server/db/db.go | 6 +- server/db/module.go | 11 +- server/gen/orm/boil_table_names.go | 2 + server/gen/orm/boil_types.go | 44 + server/gen/orm/events.go | 1013 ++++++ server/gen/orm/notifications.go | 21 - server/pubsub/events/events.go | 7 - server/pubsub/handlers/handlers.go | 146 +- server/pubsub/handlers/handlers_test.go | 166 + server/pubsub/handlers/mocks/mock_handler.go | 56 + server/pubsub/handlers/registry.go | 16 +- server/pubsub/module.go | 13 +- server/pubsub/payloads/payloads.go | 12 +- server/pubsub/pubsub.go | 114 +- server/pubsub/pubsub_test.go | 117 + server/repo/interfaces.go | 6 + server/repo/mocks/mock_repo.go | 3292 ++++++++++++++++++ server/repo/repo.go | 31 + server/repo/repo_test.go | 70 + server/rpc/handlers/v1/user.go | 3 +- server/rpc/handlers/v1/workout.go | 3 +- server/rpc/middlewares/middlewares.go | 2 +- server/testing/container/container.go | 10 +- server/testing/container/module.go | 5 + server/testing/factory/workout.go | 34 +- server/testing/factory/workout_test.go | 9 + server/trace/trace.go | 7 +- 30 files changed, 5034 insertions(+), 200 deletions(-) create mode 100644 database/migrations/022_events.up.sql create mode 100644 server/gen/orm/events.go delete mode 100644 server/pubsub/events/events.go create mode 100644 server/pubsub/handlers/handlers_test.go create mode 100644 server/pubsub/handlers/mocks/mock_handler.go create mode 100644 server/pubsub/pubsub_test.go create mode 100644 server/repo/mocks/mock_repo.go diff --git a/database/migrations/022_events.up.sql b/database/migrations/022_events.up.sql new file mode 100644 index 00000000..b7c73f13 --- /dev/null +++ b/database/migrations/022_events.up.sql @@ -0,0 +1,13 @@ +CREATE TYPE getstronger.event_topic AS ENUM ( + 'FollowedUser', + 'RequestTraced', + 'WorkoutCommentPosted' +); + +CREATE TABLE getstronger.events +( + id UUID PRIMARY KEY NOT NUll DEFAULT uuid_generate_v4(), + topic getstronger.event_topic NOT NULL, + payload JSONB NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC') +); diff --git a/go.mod b/go.mod index 77e90676..67076c52 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/google/uuid v1.6.0 github.com/jackc/pgx/v5 v5.7.1 github.com/joho/godotenv v1.5.1 + github.com/lib/pq v1.10.9 github.com/rs/cors v1.11.1 github.com/stretchr/testify v1.10.0 github.com/testcontainers/testcontainers-go v0.34.0 @@ -24,6 +25,7 @@ require ( github.com/volatiletech/sqlboiler/v4 v4.17.1 github.com/volatiletech/strmangle v0.0.8 go.uber.org/fx v1.23.0 + go.uber.org/mock v0.5.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.31.0 golang.org/x/net v0.33.0 @@ -70,7 +72,6 @@ require ( github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.17.4 // indirect - github.com/lib/pq v1.10.9 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect diff --git a/go.sum b/go.sum index d3d73617..fcc2d28a 100644 --- a/go.sum +++ b/go.sum @@ -631,6 +631,8 @@ go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg= go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= diff --git a/server/db/db.go b/server/db/db.go index 64c23476..c4acb2c8 100644 --- a/server/db/db.go +++ b/server/db/db.go @@ -11,9 +11,13 @@ import ( ) func New(c *config.Config) (*sql.DB, error) { - db, err := sql.Open("pgx", fmt.Sprintf("postgresql://%s:%s@%s/%s", c.DB.User, c.DB.Password, net.JoinHostPort(c.DB.Host, c.DB.Port), c.DB.Name)) + db, err := sql.Open("pgx", ConnectionString(c)) if err != nil { return nil, fmt.Errorf("open db: %w", err) } return db, nil } + +func ConnectionString(c *config.Config) string { + return fmt.Sprintf("postgresql://%s:%s@%s/%s?sslmode=disable", c.DB.User, c.DB.Password, net.JoinHostPort(c.DB.Host, c.DB.Port), c.DB.Name) +} diff --git a/server/db/module.go b/server/db/module.go index dcb6141f..052a2bb1 100644 --- a/server/db/module.go +++ b/server/db/module.go @@ -3,13 +3,22 @@ package db import ( "context" "database/sql" + "time" + "github.com/lib/pq" "go.uber.org/fx" + + "github.com/crlssn/getstronger/server/config" ) func Module() fx.Option { return fx.Module("db", fx.Options( - fx.Provide(New), + fx.Provide( + New, + func(c *config.Config) *pq.Listener { + return pq.NewListener(ConnectionString(c), time.Second, time.Minute, nil) + }, + ), fx.Invoke(func(l fx.Lifecycle, db *sql.DB) { l.Append(fx.Hook{ OnStart: func(ctx context.Context) error { diff --git a/server/gen/orm/boil_table_names.go b/server/gen/orm/boil_table_names.go index f29a83c8..1e56fd97 100644 --- a/server/gen/orm/boil_table_names.go +++ b/server/gen/orm/boil_table_names.go @@ -5,6 +5,7 @@ package orm var TableNames = struct { Auth string + Events string Exercises string ExercisesRoutines string Followers string @@ -17,6 +18,7 @@ var TableNames = struct { Workouts string }{ Auth: "auth", + Events: "events", Exercises: "exercises", ExercisesRoutines: "exercises_routines", Followers: "followers", diff --git a/server/gen/orm/boil_types.go b/server/gen/orm/boil_types.go index 4683fbd5..bde45947 100644 --- a/server/gen/orm/boil_types.go +++ b/server/gen/orm/boil_types.go @@ -51,6 +51,50 @@ func makeCacheKey(cols boil.Columns, nzDefaults []string) string { return str } +type EventTopic string + +// Enum values for EventTopic +const ( + EventTopicFollowedUser EventTopic = "FollowedUser" + EventTopicRequestTraced EventTopic = "RequestTraced" + EventTopicWorkoutCommentPosted EventTopic = "WorkoutCommentPosted" +) + +func AllEventTopic() []EventTopic { + return []EventTopic{ + EventTopicFollowedUser, + EventTopicRequestTraced, + EventTopicWorkoutCommentPosted, + } +} + +func (e EventTopic) IsValid() error { + switch e { + case EventTopicFollowedUser, EventTopicRequestTraced, EventTopicWorkoutCommentPosted: + return nil + default: + return errors.New("enum is not valid") + } +} + +func (e EventTopic) String() string { + return string(e) +} + +func (e EventTopic) Ordinal() int { + switch e { + case EventTopicFollowedUser: + return 0 + case EventTopicRequestTraced: + return 1 + case EventTopicWorkoutCommentPosted: + return 2 + + default: + panic(errors.New("enum is not valid")) + } +} + type NotificationType string // Enum values for NotificationType diff --git a/server/gen/orm/events.go b/server/gen/orm/events.go new file mode 100644 index 00000000..dab59a64 --- /dev/null +++ b/server/gen/orm/events.go @@ -0,0 +1,1013 @@ +// Code generated by SQLBoiler 4.17.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. +// This file is meant to be re-generated in place and/or deleted at any time. + +package orm + +import ( + "context" + "database/sql" + "fmt" + "reflect" + "strconv" + "strings" + "sync" + "time" + + "github.com/friendsofgo/errors" + "github.com/volatiletech/sqlboiler/v4/boil" + "github.com/volatiletech/sqlboiler/v4/queries" + "github.com/volatiletech/sqlboiler/v4/queries/qm" + "github.com/volatiletech/sqlboiler/v4/queries/qmhelper" + "github.com/volatiletech/sqlboiler/v4/types" + "github.com/volatiletech/strmangle" +) + +// Event is an object representing the database table. +type Event struct { + ID string `boil:"id" json:"id" toml:"id" yaml:"id"` + Topic EventTopic `boil:"topic" json:"topic" toml:"topic" yaml:"topic"` + Payload types.JSON `boil:"payload" json:"payload" toml:"payload" yaml:"payload"` + CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` + + R *eventR `boil:"-" json:"-" toml:"-" yaml:"-"` + L eventL `boil:"-" json:"-" toml:"-" yaml:"-"` +} + +var EventColumns = struct { + ID string + Topic string + Payload string + CreatedAt string +}{ + ID: "id", + Topic: "topic", + Payload: "payload", + CreatedAt: "created_at", +} + +var EventTableColumns = struct { + ID string + Topic string + Payload string + CreatedAt string +}{ + ID: "events.id", + Topic: "events.topic", + Payload: "events.payload", + CreatedAt: "events.created_at", +} + +// Generated where + +type whereHelperEventTopic struct{ field string } + +func (w whereHelperEventTopic) EQ(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.EQ, x) +} +func (w whereHelperEventTopic) NEQ(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.NEQ, x) +} +func (w whereHelperEventTopic) LT(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.LT, x) +} +func (w whereHelperEventTopic) LTE(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.LTE, x) +} +func (w whereHelperEventTopic) GT(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.GT, x) +} +func (w whereHelperEventTopic) GTE(x EventTopic) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.GTE, x) +} +func (w whereHelperEventTopic) IN(slice []EventTopic) qm.QueryMod { + values := make([]interface{}, 0, len(slice)) + for _, value := range slice { + values = append(values, value) + } + return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...) +} +func (w whereHelperEventTopic) NIN(slice []EventTopic) qm.QueryMod { + values := make([]interface{}, 0, len(slice)) + for _, value := range slice { + values = append(values, value) + } + return qm.WhereNotIn(fmt.Sprintf("%s NOT IN ?", w.field), values...) +} + +type whereHelpertypes_JSON struct{ field string } + +func (w whereHelpertypes_JSON) EQ(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.EQ, x) +} +func (w whereHelpertypes_JSON) NEQ(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.NEQ, x) +} +func (w whereHelpertypes_JSON) LT(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.LT, x) +} +func (w whereHelpertypes_JSON) LTE(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.LTE, x) +} +func (w whereHelpertypes_JSON) GT(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.GT, x) +} +func (w whereHelpertypes_JSON) GTE(x types.JSON) qm.QueryMod { + return qmhelper.Where(w.field, qmhelper.GTE, x) +} + +var EventWhere = struct { + ID whereHelperstring + Topic whereHelperEventTopic + Payload whereHelpertypes_JSON + CreatedAt whereHelpertime_Time +}{ + ID: whereHelperstring{field: "\"getstronger\".\"events\".\"id\""}, + Topic: whereHelperEventTopic{field: "\"getstronger\".\"events\".\"topic\""}, + Payload: whereHelpertypes_JSON{field: "\"getstronger\".\"events\".\"payload\""}, + CreatedAt: whereHelpertime_Time{field: "\"getstronger\".\"events\".\"created_at\""}, +} + +// EventRels is where relationship names are stored. +var EventRels = struct { +}{} + +// eventR is where relationships are stored. +type eventR struct { +} + +// NewStruct creates a new relationship struct +func (*eventR) NewStruct() *eventR { + return &eventR{} +} + +// eventL is where Load methods for each relationship are stored. +type eventL struct{} + +var ( + eventAllColumns = []string{"id", "topic", "payload", "created_at"} + eventColumnsWithoutDefault = []string{"topic", "payload"} + eventColumnsWithDefault = []string{"id", "created_at"} + eventPrimaryKeyColumns = []string{"id"} + eventGeneratedColumns = []string{} +) + +type ( + // EventSlice is an alias for a slice of pointers to Event. + // This should almost always be used instead of []Event. + EventSlice []*Event + // EventHook is the signature for custom Event hook methods + EventHook func(context.Context, boil.ContextExecutor, *Event) error + + eventQuery struct { + *queries.Query + } +) + +// Cache for insert, update and upsert +var ( + eventType = reflect.TypeOf(&Event{}) + eventMapping = queries.MakeStructMapping(eventType) + eventPrimaryKeyMapping, _ = queries.BindMapping(eventType, eventMapping, eventPrimaryKeyColumns) + eventInsertCacheMut sync.RWMutex + eventInsertCache = make(map[string]insertCache) + eventUpdateCacheMut sync.RWMutex + eventUpdateCache = make(map[string]updateCache) + eventUpsertCacheMut sync.RWMutex + eventUpsertCache = make(map[string]insertCache) +) + +var ( + // Force time package dependency for automated UpdatedAt/CreatedAt. + _ = time.Second + // Force qmhelper dependency for where clause generation (which doesn't + // always happen) + _ = qmhelper.Where +) + +var eventAfterSelectMu sync.Mutex +var eventAfterSelectHooks []EventHook + +var eventBeforeInsertMu sync.Mutex +var eventBeforeInsertHooks []EventHook +var eventAfterInsertMu sync.Mutex +var eventAfterInsertHooks []EventHook + +var eventBeforeUpdateMu sync.Mutex +var eventBeforeUpdateHooks []EventHook +var eventAfterUpdateMu sync.Mutex +var eventAfterUpdateHooks []EventHook + +var eventBeforeDeleteMu sync.Mutex +var eventBeforeDeleteHooks []EventHook +var eventAfterDeleteMu sync.Mutex +var eventAfterDeleteHooks []EventHook + +var eventBeforeUpsertMu sync.Mutex +var eventBeforeUpsertHooks []EventHook +var eventAfterUpsertMu sync.Mutex +var eventAfterUpsertHooks []EventHook + +// doAfterSelectHooks executes all "after Select" hooks. +func (o *Event) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventAfterSelectHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doBeforeInsertHooks executes all "before insert" hooks. +func (o *Event) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventBeforeInsertHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doAfterInsertHooks executes all "after Insert" hooks. +func (o *Event) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventAfterInsertHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doBeforeUpdateHooks executes all "before Update" hooks. +func (o *Event) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventBeforeUpdateHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doAfterUpdateHooks executes all "after Update" hooks. +func (o *Event) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventAfterUpdateHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doBeforeDeleteHooks executes all "before Delete" hooks. +func (o *Event) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventBeforeDeleteHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doAfterDeleteHooks executes all "after Delete" hooks. +func (o *Event) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventAfterDeleteHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doBeforeUpsertHooks executes all "before Upsert" hooks. +func (o *Event) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventBeforeUpsertHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// doAfterUpsertHooks executes all "after Upsert" hooks. +func (o *Event) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { + if boil.HooksAreSkipped(ctx) { + return nil + } + + for _, hook := range eventAfterUpsertHooks { + if err := hook(ctx, exec, o); err != nil { + return err + } + } + + return nil +} + +// AddEventHook registers your hook function for all future operations. +func AddEventHook(hookPoint boil.HookPoint, eventHook EventHook) { + switch hookPoint { + case boil.AfterSelectHook: + eventAfterSelectMu.Lock() + eventAfterSelectHooks = append(eventAfterSelectHooks, eventHook) + eventAfterSelectMu.Unlock() + case boil.BeforeInsertHook: + eventBeforeInsertMu.Lock() + eventBeforeInsertHooks = append(eventBeforeInsertHooks, eventHook) + eventBeforeInsertMu.Unlock() + case boil.AfterInsertHook: + eventAfterInsertMu.Lock() + eventAfterInsertHooks = append(eventAfterInsertHooks, eventHook) + eventAfterInsertMu.Unlock() + case boil.BeforeUpdateHook: + eventBeforeUpdateMu.Lock() + eventBeforeUpdateHooks = append(eventBeforeUpdateHooks, eventHook) + eventBeforeUpdateMu.Unlock() + case boil.AfterUpdateHook: + eventAfterUpdateMu.Lock() + eventAfterUpdateHooks = append(eventAfterUpdateHooks, eventHook) + eventAfterUpdateMu.Unlock() + case boil.BeforeDeleteHook: + eventBeforeDeleteMu.Lock() + eventBeforeDeleteHooks = append(eventBeforeDeleteHooks, eventHook) + eventBeforeDeleteMu.Unlock() + case boil.AfterDeleteHook: + eventAfterDeleteMu.Lock() + eventAfterDeleteHooks = append(eventAfterDeleteHooks, eventHook) + eventAfterDeleteMu.Unlock() + case boil.BeforeUpsertHook: + eventBeforeUpsertMu.Lock() + eventBeforeUpsertHooks = append(eventBeforeUpsertHooks, eventHook) + eventBeforeUpsertMu.Unlock() + case boil.AfterUpsertHook: + eventAfterUpsertMu.Lock() + eventAfterUpsertHooks = append(eventAfterUpsertHooks, eventHook) + eventAfterUpsertMu.Unlock() + } +} + +// One returns a single event record from the query. +func (q eventQuery) One(ctx context.Context, exec boil.ContextExecutor) (*Event, error) { + o := &Event{} + + queries.SetLimit(q.Query, 1) + + err := q.Bind(ctx, exec, o) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, sql.ErrNoRows + } + return nil, errors.Wrap(err, "orm: failed to execute a one query for events") + } + + if err := o.doAfterSelectHooks(ctx, exec); err != nil { + return o, err + } + + return o, nil +} + +// All returns all Event records from the query. +func (q eventQuery) All(ctx context.Context, exec boil.ContextExecutor) (EventSlice, error) { + var o []*Event + + err := q.Bind(ctx, exec, &o) + if err != nil { + return nil, errors.Wrap(err, "orm: failed to assign all query results to Event slice") + } + + if len(eventAfterSelectHooks) != 0 { + for _, obj := range o { + if err := obj.doAfterSelectHooks(ctx, exec); err != nil { + return o, err + } + } + } + + return o, nil +} + +// Count returns the count of all Event records in the query. +func (q eventQuery) Count(ctx context.Context, exec boil.ContextExecutor) (int64, error) { + var count int64 + + queries.SetSelect(q.Query, nil) + queries.SetCount(q.Query) + + err := q.Query.QueryRowContext(ctx, exec).Scan(&count) + if err != nil { + return 0, errors.Wrap(err, "orm: failed to count events rows") + } + + return count, nil +} + +// Exists checks if the row exists in the table. +func (q eventQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) { + var count int64 + + queries.SetSelect(q.Query, nil) + queries.SetCount(q.Query) + queries.SetLimit(q.Query, 1) + + err := q.Query.QueryRowContext(ctx, exec).Scan(&count) + if err != nil { + return false, errors.Wrap(err, "orm: failed to check if events exists") + } + + return count > 0, nil +} + +// Events retrieves all the records using an executor. +func Events(mods ...qm.QueryMod) eventQuery { + mods = append(mods, qm.From("\"getstronger\".\"events\"")) + q := NewQuery(mods...) + if len(queries.GetSelect(q)) == 0 { + queries.SetSelect(q, []string{"\"getstronger\".\"events\".*"}) + } + + return eventQuery{q} +} + +// FindEvent retrieves a single record by ID with an executor. +// If selectCols is empty Find will return all columns. +func FindEvent(ctx context.Context, exec boil.ContextExecutor, iD string, selectCols ...string) (*Event, error) { + eventObj := &Event{} + + sel := "*" + if len(selectCols) > 0 { + sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",") + } + query := fmt.Sprintf( + "select %s from \"getstronger\".\"events\" where \"id\"=$1", sel, + ) + + q := queries.Raw(query, iD) + + err := q.Bind(ctx, exec, eventObj) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, sql.ErrNoRows + } + return nil, errors.Wrap(err, "orm: unable to select from events") + } + + if err = eventObj.doAfterSelectHooks(ctx, exec); err != nil { + return eventObj, err + } + + return eventObj, nil +} + +// Insert a single record using an executor. +// See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts. +func (o *Event) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error { + if o == nil { + return errors.New("orm: no events provided for insertion") + } + + var err error + if !boil.TimestampsAreSkipped(ctx) { + currTime := time.Now().In(boil.GetLocation()) + + if o.CreatedAt.IsZero() { + o.CreatedAt = currTime + } + } + + if err := o.doBeforeInsertHooks(ctx, exec); err != nil { + return err + } + + nzDefaults := queries.NonZeroDefaultSet(eventColumnsWithDefault, o) + + key := makeCacheKey(columns, nzDefaults) + eventInsertCacheMut.RLock() + cache, cached := eventInsertCache[key] + eventInsertCacheMut.RUnlock() + + if !cached { + wl, returnColumns := columns.InsertColumnSet( + eventAllColumns, + eventColumnsWithDefault, + eventColumnsWithoutDefault, + nzDefaults, + ) + + cache.valueMapping, err = queries.BindMapping(eventType, eventMapping, wl) + if err != nil { + return err + } + cache.retMapping, err = queries.BindMapping(eventType, eventMapping, returnColumns) + if err != nil { + return err + } + if len(wl) != 0 { + cache.query = fmt.Sprintf("INSERT INTO \"getstronger\".\"events\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1)) + } else { + cache.query = "INSERT INTO \"getstronger\".\"events\" %sDEFAULT VALUES%s" + } + + var queryOutput, queryReturning string + + if len(cache.retMapping) != 0 { + queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\"")) + } + + cache.query = fmt.Sprintf(cache.query, queryOutput, queryReturning) + } + + value := reflect.Indirect(reflect.ValueOf(o)) + vals := queries.ValuesFromMapping(value, cache.valueMapping) + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, cache.query) + fmt.Fprintln(writer, vals) + } + + if len(cache.retMapping) != 0 { + err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...) + } else { + _, err = exec.ExecContext(ctx, cache.query, vals...) + } + + if err != nil { + return errors.Wrap(err, "orm: unable to insert into events") + } + + if !cached { + eventInsertCacheMut.Lock() + eventInsertCache[key] = cache + eventInsertCacheMut.Unlock() + } + + return o.doAfterInsertHooks(ctx, exec) +} + +// Update uses an executor to update the Event. +// See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. +// Update does not automatically update the record in case of default values. Use .Reload() to refresh the records. +func (o *Event) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error) { + var err error + if err = o.doBeforeUpdateHooks(ctx, exec); err != nil { + return 0, err + } + key := makeCacheKey(columns, nil) + eventUpdateCacheMut.RLock() + cache, cached := eventUpdateCache[key] + eventUpdateCacheMut.RUnlock() + + if !cached { + wl := columns.UpdateColumnSet( + eventAllColumns, + eventPrimaryKeyColumns, + ) + + if !columns.IsWhitelist() { + wl = strmangle.SetComplement(wl, []string{"created_at"}) + } + if len(wl) == 0 { + return 0, errors.New("orm: unable to update events, could not build whitelist") + } + + cache.query = fmt.Sprintf("UPDATE \"getstronger\".\"events\" SET %s WHERE %s", + strmangle.SetParamNames("\"", "\"", 1, wl), + strmangle.WhereClause("\"", "\"", len(wl)+1, eventPrimaryKeyColumns), + ) + cache.valueMapping, err = queries.BindMapping(eventType, eventMapping, append(wl, eventPrimaryKeyColumns...)) + if err != nil { + return 0, err + } + } + + values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping) + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, cache.query) + fmt.Fprintln(writer, values) + } + var result sql.Result + result, err = exec.ExecContext(ctx, cache.query, values...) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to update events row") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: failed to get rows affected by update for events") + } + + if !cached { + eventUpdateCacheMut.Lock() + eventUpdateCache[key] = cache + eventUpdateCacheMut.Unlock() + } + + return rowsAff, o.doAfterUpdateHooks(ctx, exec) +} + +// UpdateAll updates all rows with the specified column values. +func (q eventQuery) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { + queries.SetUpdate(q.Query, cols) + + result, err := q.Query.ExecContext(ctx, exec) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to update all for events") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: unable to retrieve rows affected for events") + } + + return rowsAff, nil +} + +// UpdateAll updates all rows with the specified column values, using an executor. +func (o EventSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { + ln := int64(len(o)) + if ln == 0 { + return 0, nil + } + + if len(cols) == 0 { + return 0, errors.New("orm: update all requires at least one column argument") + } + + colNames := make([]string, len(cols)) + args := make([]interface{}, len(cols)) + + i := 0 + for name, value := range cols { + colNames[i] = name + args[i] = value + i++ + } + + // Append all of the primary key values for each column + for _, obj := range o { + pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), eventPrimaryKeyMapping) + args = append(args, pkeyArgs...) + } + + sql := fmt.Sprintf("UPDATE \"getstronger\".\"events\" SET %s WHERE %s", + strmangle.SetParamNames("\"", "\"", 1, colNames), + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, eventPrimaryKeyColumns, len(o))) + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, sql) + fmt.Fprintln(writer, args...) + } + result, err := exec.ExecContext(ctx, sql, args...) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to update all in event slice") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: unable to retrieve rows affected all in update all event") + } + return rowsAff, nil +} + +// Upsert attempts an insert using an executor, and does an update or ignore on conflict. +// See boil.Columns documentation for how to properly use updateColumns and insertColumns. +func (o *Event) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns, opts ...UpsertOptionFunc) error { + if o == nil { + return errors.New("orm: no events provided for upsert") + } + if !boil.TimestampsAreSkipped(ctx) { + currTime := time.Now().In(boil.GetLocation()) + + if o.CreatedAt.IsZero() { + o.CreatedAt = currTime + } + } + + if err := o.doBeforeUpsertHooks(ctx, exec); err != nil { + return err + } + + nzDefaults := queries.NonZeroDefaultSet(eventColumnsWithDefault, o) + + // Build cache key in-line uglily - mysql vs psql problems + buf := strmangle.GetBuffer() + if updateOnConflict { + buf.WriteByte('t') + } else { + buf.WriteByte('f') + } + buf.WriteByte('.') + for _, c := range conflictColumns { + buf.WriteString(c) + } + buf.WriteByte('.') + buf.WriteString(strconv.Itoa(updateColumns.Kind)) + for _, c := range updateColumns.Cols { + buf.WriteString(c) + } + buf.WriteByte('.') + buf.WriteString(strconv.Itoa(insertColumns.Kind)) + for _, c := range insertColumns.Cols { + buf.WriteString(c) + } + buf.WriteByte('.') + for _, c := range nzDefaults { + buf.WriteString(c) + } + key := buf.String() + strmangle.PutBuffer(buf) + + eventUpsertCacheMut.RLock() + cache, cached := eventUpsertCache[key] + eventUpsertCacheMut.RUnlock() + + var err error + + if !cached { + insert, _ := insertColumns.InsertColumnSet( + eventAllColumns, + eventColumnsWithDefault, + eventColumnsWithoutDefault, + nzDefaults, + ) + + update := updateColumns.UpdateColumnSet( + eventAllColumns, + eventPrimaryKeyColumns, + ) + + if updateOnConflict && len(update) == 0 { + return errors.New("orm: unable to upsert events, could not build update column list") + } + + ret := strmangle.SetComplement(eventAllColumns, strmangle.SetIntersect(insert, update)) + + conflict := conflictColumns + if len(conflict) == 0 && updateOnConflict && len(update) != 0 { + if len(eventPrimaryKeyColumns) == 0 { + return errors.New("orm: unable to upsert events, could not build conflict column list") + } + + conflict = make([]string, len(eventPrimaryKeyColumns)) + copy(conflict, eventPrimaryKeyColumns) + } + cache.query = buildUpsertQueryPostgres(dialect, "\"getstronger\".\"events\"", updateOnConflict, ret, update, conflict, insert, opts...) + + cache.valueMapping, err = queries.BindMapping(eventType, eventMapping, insert) + if err != nil { + return err + } + if len(ret) != 0 { + cache.retMapping, err = queries.BindMapping(eventType, eventMapping, ret) + if err != nil { + return err + } + } + } + + value := reflect.Indirect(reflect.ValueOf(o)) + vals := queries.ValuesFromMapping(value, cache.valueMapping) + var returns []interface{} + if len(cache.retMapping) != 0 { + returns = queries.PtrsFromMapping(value, cache.retMapping) + } + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, cache.query) + fmt.Fprintln(writer, vals) + } + if len(cache.retMapping) != 0 { + err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(returns...) + if errors.Is(err, sql.ErrNoRows) { + err = nil // Postgres doesn't return anything when there's no update + } + } else { + _, err = exec.ExecContext(ctx, cache.query, vals...) + } + if err != nil { + return errors.Wrap(err, "orm: unable to upsert events") + } + + if !cached { + eventUpsertCacheMut.Lock() + eventUpsertCache[key] = cache + eventUpsertCacheMut.Unlock() + } + + return o.doAfterUpsertHooks(ctx, exec) +} + +// Delete deletes a single Event record with an executor. +// Delete will match against the primary key column to find the record to delete. +func (o *Event) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) { + if o == nil { + return 0, errors.New("orm: no Event provided for delete") + } + + if err := o.doBeforeDeleteHooks(ctx, exec); err != nil { + return 0, err + } + + args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), eventPrimaryKeyMapping) + sql := "DELETE FROM \"getstronger\".\"events\" WHERE \"id\"=$1" + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, sql) + fmt.Fprintln(writer, args...) + } + result, err := exec.ExecContext(ctx, sql, args...) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to delete from events") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: failed to get rows affected by delete for events") + } + + if err := o.doAfterDeleteHooks(ctx, exec); err != nil { + return 0, err + } + + return rowsAff, nil +} + +// DeleteAll deletes all matching rows. +func (q eventQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { + if q.Query == nil { + return 0, errors.New("orm: no eventQuery provided for delete all") + } + + queries.SetDelete(q.Query) + + result, err := q.Query.ExecContext(ctx, exec) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to delete all from events") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: failed to get rows affected by deleteall for events") + } + + return rowsAff, nil +} + +// DeleteAll deletes all rows in the slice, using an executor. +func (o EventSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { + if len(o) == 0 { + return 0, nil + } + + if len(eventBeforeDeleteHooks) != 0 { + for _, obj := range o { + if err := obj.doBeforeDeleteHooks(ctx, exec); err != nil { + return 0, err + } + } + } + + var args []interface{} + for _, obj := range o { + pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), eventPrimaryKeyMapping) + args = append(args, pkeyArgs...) + } + + sql := "DELETE FROM \"getstronger\".\"events\" WHERE " + + strmangle.WhereInClause(string(dialect.LQ), string(dialect.RQ), 1, eventPrimaryKeyColumns, len(o)) + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, sql) + fmt.Fprintln(writer, args) + } + result, err := exec.ExecContext(ctx, sql, args...) + if err != nil { + return 0, errors.Wrap(err, "orm: unable to delete all from event slice") + } + + rowsAff, err := result.RowsAffected() + if err != nil { + return 0, errors.Wrap(err, "orm: failed to get rows affected by deleteall for events") + } + + if len(eventAfterDeleteHooks) != 0 { + for _, obj := range o { + if err := obj.doAfterDeleteHooks(ctx, exec); err != nil { + return 0, err + } + } + } + + return rowsAff, nil +} + +// Reload refetches the object from the database +// using the primary keys with an executor. +func (o *Event) Reload(ctx context.Context, exec boil.ContextExecutor) error { + ret, err := FindEvent(ctx, exec, o.ID) + if err != nil { + return err + } + + *o = *ret + return nil +} + +// ReloadAll refetches every row with matching primary key column values +// and overwrites the original object slice with the newly updated slice. +func (o *EventSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error { + if o == nil || len(*o) == 0 { + return nil + } + + slice := EventSlice{} + var args []interface{} + for _, obj := range *o { + pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), eventPrimaryKeyMapping) + args = append(args, pkeyArgs...) + } + + sql := "SELECT \"getstronger\".\"events\".* FROM \"getstronger\".\"events\" WHERE " + + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 1, eventPrimaryKeyColumns, len(*o)) + + q := queries.Raw(sql, args...) + + err := q.Bind(ctx, exec, &slice) + if err != nil { + return errors.Wrap(err, "orm: unable to reload all in EventSlice") + } + + *o = slice + + return nil +} + +// EventExists checks if the Event row exists. +func EventExists(ctx context.Context, exec boil.ContextExecutor, iD string) (bool, error) { + var exists bool + sql := "select exists(select 1 from \"getstronger\".\"events\" where \"id\"=$1 limit 1)" + + if boil.IsDebug(ctx) { + writer := boil.DebugWriterFrom(ctx) + fmt.Fprintln(writer, sql) + fmt.Fprintln(writer, iD) + } + row := exec.QueryRowContext(ctx, sql, iD) + + err := row.Scan(&exists) + if err != nil { + return false, errors.Wrap(err, "orm: unable to check if events exists") + } + + return exists, nil +} + +// Exists checks if the Event row exists. +func (o *Event) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) { + return EventExists(ctx, exec, o.ID) +} diff --git a/server/gen/orm/notifications.go b/server/gen/orm/notifications.go index d285cdc4..c917efa6 100644 --- a/server/gen/orm/notifications.go +++ b/server/gen/orm/notifications.go @@ -105,27 +105,6 @@ func (w whereHelperNotificationType) NIN(slice []NotificationType) qm.QueryMod { return qm.WhereNotIn(fmt.Sprintf("%s NOT IN ?", w.field), values...) } -type whereHelpertypes_JSON struct{ field string } - -func (w whereHelpertypes_JSON) EQ(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.EQ, x) -} -func (w whereHelpertypes_JSON) NEQ(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.NEQ, x) -} -func (w whereHelpertypes_JSON) LT(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.LT, x) -} -func (w whereHelpertypes_JSON) LTE(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.LTE, x) -} -func (w whereHelpertypes_JSON) GT(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.GT, x) -} -func (w whereHelpertypes_JSON) GTE(x types.JSON) qm.QueryMod { - return qmhelper.Where(w.field, qmhelper.GTE, x) -} - var NotificationWhere = struct { ID whereHelperstring UserID whereHelperstring diff --git a/server/pubsub/events/events.go b/server/pubsub/events/events.go deleted file mode 100644 index aa746265..00000000 --- a/server/pubsub/events/events.go +++ /dev/null @@ -1,7 +0,0 @@ -package events - -const ( - UserFollowed = "user:followed" - RequestTraced = "request:traced" - WorkoutCommentPosted = "workout_comment:posted" -) diff --git a/server/pubsub/handlers/handlers.go b/server/pubsub/handlers/handlers.go index 69bf17e3..3e945033 100644 --- a/server/pubsub/handlers/handlers.go +++ b/server/pubsub/handlers/handlers.go @@ -2,6 +2,7 @@ package handlers import ( "context" + "encoding/json" "time" "go.uber.org/zap" @@ -13,12 +14,13 @@ import ( const timeout = 5 * time.Second +//go:generate mockgen -package mock_handlers -source=handlers.go -destination=mocks/mock_handler.go Handler type Handler interface { - HandlePayload(payload any) + HandlePayload(payload string) } var ( - _ Handler = (*UserFollowed)(nil) + _ Handler = (*FollowedUser)(nil) _ Handler = (*RequestTraced)(nil) _ Handler = (*WorkoutCommentPosted)(nil) ) @@ -32,21 +34,22 @@ func NewRequestTraced(log *zap.Logger, repo repo.Repo) *RequestTraced { return &RequestTraced{log, repo} } -func (h *RequestTraced) HandlePayload(payload any) { +func (h *RequestTraced) HandlePayload(payload string) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - switch t := payload.(type) { - case *payloads.RequestTraced: - if err := h.repo.StoreTrace(ctx, repo.StoreTraceParams{ - Request: t.Request, - DurationMS: t.DurationMS, - StatusCode: t.StatusCode, - }); err != nil { - h.log.Error("trace store failed", zap.Error(err)) - } - default: - h.log.Error("unexpected event type", zap.Any("event", payload)) + var p payloads.RequestTraced + if err := json.Unmarshal([]byte(payload), &p); err != nil { + h.log.Error("unmarshal payload", zap.Error(err)) + return + } + + if err := h.repo.StoreTrace(ctx, repo.StoreTraceParams{ + Request: p.Request, + DurationMS: p.DurationMS, + StatusCode: p.StatusCode, + }); err != nil { + h.log.Error("trace store failed", zap.Error(err)) } } @@ -59,80 +62,85 @@ func NewWorkoutCommentPosted(log *zap.Logger, repo repo.Repo) *WorkoutCommentPos return &WorkoutCommentPosted{log, repo} } -func (w *WorkoutCommentPosted) HandlePayload(payload any) { +func (w *WorkoutCommentPosted) HandlePayload(payload string) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - switch t := payload.(type) { - case *payloads.WorkoutCommentPosted: - comment, err := w.repo.GetWorkoutComment(ctx, - repo.GetWorkoutCommentWithID(t.CommentID), - ) - if err != nil { - w.log.Error("get workout comment", zap.Error(err)) - return - } + var p payloads.WorkoutCommentPosted + if err := json.Unmarshal([]byte(payload), &p); err != nil { + w.log.Error("unmarshal payload", zap.Error(err)) + return + } - workout, err := w.repo.GetWorkout(ctx, - repo.GetWorkoutWithID(comment.WorkoutID), - repo.GetWorkoutWithComments(), - ) - if err != nil { - w.log.Error("get workout", zap.Error(err)) - return - } + comment, err := w.repo.GetWorkoutComment(ctx, + repo.GetWorkoutCommentWithID(p.CommentID), + ) + if err != nil { + w.log.Error("get workout comment", zap.Error(err)) + return + } - mapUserIDs := make(map[string]struct{}) - for _, c := range workout.R.WorkoutComments { - if comment.UserID == c.UserID { - // Don't notify own comments. - continue - } - mapUserIDs[c.UserID] = struct{}{} + workout, err := w.repo.GetWorkout(ctx, + repo.GetWorkoutWithID(comment.WorkoutID), + repo.GetWorkoutWithComments(), + ) + if err != nil { + w.log.Error("get workout", zap.Error(err)) + return + } + + mapUserIDs := make(map[string]struct{}) + if comment.UserID != workout.UserID { + mapUserIDs[workout.UserID] = struct{}{} + } + for _, c := range workout.R.WorkoutComments { + if comment.UserID == c.UserID { + // Don't notify own comments. + continue } + mapUserIDs[c.UserID] = struct{}{} + } - for userID := range mapUserIDs { - if err = w.repo.CreateNotification(ctx, repo.CreateNotificationParams{ - Type: orm.NotificationTypeWorkoutComment, - UserID: userID, - Payload: repo.NotificationPayload{ - ActorID: comment.UserID, - WorkoutID: comment.WorkoutID, - }, - }); err != nil { - w.log.Error("create notification", zap.Error(err)) - } + for userID := range mapUserIDs { + if err = w.repo.CreateNotification(ctx, repo.CreateNotificationParams{ + Type: orm.NotificationTypeWorkoutComment, + UserID: userID, + Payload: repo.NotificationPayload{ + ActorID: comment.UserID, + WorkoutID: comment.WorkoutID, + }, + }); err != nil { + w.log.Error("create notification", zap.Error(err)) } - default: - w.log.Error("unexpected event type", zap.Any("event", payload)) } } -type UserFollowed struct { +type FollowedUser struct { log *zap.Logger repo repo.Repo } -func NewUserFollowed(log *zap.Logger, repo repo.Repo) *UserFollowed { - return &UserFollowed{log, repo} +func NewFollowedUser(log *zap.Logger, repo repo.Repo) *FollowedUser { + return &FollowedUser{log, repo} } -func (u *UserFollowed) HandlePayload(payload any) { +func (u *FollowedUser) HandlePayload(payload string) { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - switch t := payload.(type) { - case *payloads.UserFollowed: - if err := u.repo.CreateNotification(ctx, repo.CreateNotificationParams{ - Type: orm.NotificationTypeFollow, - UserID: t.FolloweeID, - Payload: repo.NotificationPayload{ - ActorID: t.FollowerID, - }, - }); err != nil { - u.log.Error("create notification", zap.Error(err)) - } - default: - u.log.Error("unexpected event type", zap.Any("event", payload)) + var p payloads.UserFollowed + if err := json.Unmarshal([]byte(payload), &p); err != nil { + u.log.Error("unmarshal payload", zap.Error(err)) + return + } + + if err := u.repo.CreateNotification(ctx, repo.CreateNotificationParams{ + Type: orm.NotificationTypeFollow, + UserID: p.FolloweeID, + Payload: repo.NotificationPayload{ + ActorID: p.FollowerID, + }, + }); err != nil { + u.log.Error("create notification", zap.Error(err)) } } diff --git a/server/pubsub/handlers/handlers_test.go b/server/pubsub/handlers/handlers_test.go new file mode 100644 index 00000000..daf185ff --- /dev/null +++ b/server/pubsub/handlers/handlers_test.go @@ -0,0 +1,166 @@ +//nolint:contextcheck +package handlers_test + +import ( + "context" + "encoding/json" + "fmt" + "testing" + + "github.com/google/uuid" + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + "go.uber.org/zap" + + "github.com/crlssn/getstronger/server/gen/orm" + "github.com/crlssn/getstronger/server/pubsub/handlers" + "github.com/crlssn/getstronger/server/pubsub/payloads" + "github.com/crlssn/getstronger/server/repo" + mock_repo "github.com/crlssn/getstronger/server/repo/mocks" + "github.com/crlssn/getstronger/server/testing/container" + "github.com/crlssn/getstronger/server/testing/factory" +) + +func TestRequestTraced_HandlePayload(t *testing.T) { + t.Parallel() + controller := gomock.NewController(t) + repoMock := mock_repo.NewMockRepo(controller) + handler := handlers.NewRequestTraced(zap.NewExample(), repoMock) + + t.Run("ok_request_traced", func(t *testing.T) { + t.Parallel() + payload := payloads.RequestTraced{ + Request: "GET /api/test", + DurationMS: 200, + StatusCode: 200, + } + + repoMock.EXPECT().StoreTrace(gomock.Any(), repo.StoreTraceParams{ + Request: payload.Request, + DurationMS: payload.DurationMS, + StatusCode: payload.StatusCode, + }) + + bytes, err := json.Marshal(payload) + require.NoError(t, err) + + handler.HandlePayload(string(bytes)) + }) + + t.Run("ok_invalid_payload", func(t *testing.T) { + t.Parallel() + handler.HandlePayload("invalid_payload") + repoMock.EXPECT().StoreTrace(gomock.Any(), gomock.Any()).Times(0) + }) + + t.Cleanup(func() { + controller.Finish() + }) +} + +func TestWorkoutCommentPosted_HandlePayload(t *testing.T) { + t.Parallel() + + ctx := context.Background() + c := container.NewContainer(ctx) + f := factory.NewFactory(c.DB) + handler := handlers.NewWorkoutCommentPosted(zap.NewExample(), repo.New(c.DB)) + + t.Run("ok_workout_comment_posted", func(t *testing.T) { + t.Parallel() + payload := payloads.WorkoutCommentPosted{ + CommentID: uuid.NewString(), + } + + f.NewUser(factory.UserID(factory.UUID(0))) + f.NewUser(factory.UserID(factory.UUID(1))) + f.NewUser(factory.UserID(factory.UUID(2))) + f.NewUser(factory.UserID(factory.UUID(3))) + + workout := f.NewWorkout( + factory.WorkoutUserID(factory.UUID(0)), + ) + f.NewWorkoutComment( + factory.WorkoutCommentUserID(factory.UUID(1)), + factory.WorkoutCommentWorkoutID(workout.ID), + ) + f.NewWorkoutComment( + factory.WorkoutCommentUserID(factory.UUID(2)), + factory.WorkoutCommentWorkoutID(workout.ID), + ) + f.NewWorkoutComment( + factory.WorkoutCommentUserID(factory.UUID(3)), + factory.WorkoutCommentWorkoutID(workout.ID), + ) + f.NewWorkoutComment( + factory.WorkoutCommentID(payload.CommentID), + factory.WorkoutCommentUserID(factory.UUID(3)), + factory.WorkoutCommentWorkoutID(workout.ID), + ) + + bytes, err := json.Marshal(payload) + require.NoError(t, err) + + handler.HandlePayload(string(bytes)) + + count, err := orm.Notifications(orm.NotificationWhere.UserID.IN( + []string{factory.UUID(0), factory.UUID(1), factory.UUID(2)}, + )).Count(ctx, c.DB) + require.NoError(t, err) + require.Equal(t, 3, int(count)) + + exists, err := orm.Notifications(orm.NotificationWhere.UserID.EQ(factory.UUID(3))).Exists(ctx, c.DB) + require.NoError(t, err) + require.False(t, exists) + }) + + t.Run("ok_invalid_payload", func(t *testing.T) { + t.Parallel() + handler.HandlePayload("invalid_payload") + }) + + t.Cleanup(func() { + if err := c.Terminate(ctx); err != nil { + t.Fatal(fmt.Errorf("failed to terminate container: %w", err)) + } + }) +} + +func TestFollowedUser_HandlePayload(t *testing.T) { + t.Parallel() + + controller := gomock.NewController(t) + repoMock := mock_repo.NewMockRepo(controller) + handler := handlers.NewFollowedUser(zap.NewExample(), repoMock) + + t.Run("ok_user_followed", func(t *testing.T) { + t.Parallel() + payload := payloads.UserFollowed{ + FollowerID: "follower_id", + FolloweeID: "followee_id", + } + + repoMock.EXPECT().CreateNotification(gomock.Any(), repo.CreateNotificationParams{ + Type: orm.NotificationTypeFollow, + UserID: payload.FolloweeID, + Payload: repo.NotificationPayload{ + ActorID: payload.FollowerID, + }, + }) + + bytes, err := json.Marshal(payload) + require.NoError(t, err) + + handler.HandlePayload(string(bytes)) + }) + + t.Run("ok_invalid_payload", func(t *testing.T) { + t.Parallel() + handler.HandlePayload("invalid_payload") + repoMock.EXPECT().StoreTrace(gomock.Any(), gomock.Any()).Times(0) + }) + + t.Cleanup(func() { + controller.Finish() + }) +} diff --git a/server/pubsub/handlers/mocks/mock_handler.go b/server/pubsub/handlers/mocks/mock_handler.go new file mode 100644 index 00000000..2e2a9f42 --- /dev/null +++ b/server/pubsub/handlers/mocks/mock_handler.go @@ -0,0 +1,56 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: handlers.go +// +// Generated by this command: +// +// mockgen -package mock_handlers -source=handlers.go -destination=mocks/mock_handler.go Handler +// + +// Package mock_handlers is a generated GoMock package. +package mock_handlers + +import ( + reflect "reflect" + + gomock "go.uber.org/mock/gomock" +) + +// MockHandler is a mock of Handler interface. +type MockHandler struct { + ctrl *gomock.Controller + recorder *MockHandlerMockRecorder +} + +// MockHandlerMockRecorder is the mock recorder for MockHandler. +type MockHandlerMockRecorder struct { + mock *MockHandler +} + +// NewMockHandler creates a new mock instance. +func NewMockHandler(ctrl *gomock.Controller) *MockHandler { + mock := &MockHandler{ctrl: ctrl} + mock.recorder = &MockHandlerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockHandler) EXPECT() *MockHandlerMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockHandler) ISGOMOCK() struct{} { + return struct{}{} +} + +// HandlePayload mocks base method. +func (m *MockHandler) HandlePayload(payload string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "HandlePayload", payload) +} + +// HandlePayload indicates an expected call of HandlePayload. +func (mr *MockHandlerMockRecorder) HandlePayload(payload any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandlePayload", reflect.TypeOf((*MockHandler)(nil).HandlePayload), payload) +} diff --git a/server/pubsub/handlers/registry.go b/server/pubsub/handlers/registry.go index 1aaf3250..bfeb2b33 100644 --- a/server/pubsub/handlers/registry.go +++ b/server/pubsub/handlers/registry.go @@ -3,31 +3,31 @@ package handlers import ( "go.uber.org/fx" - "github.com/crlssn/getstronger/server/pubsub/events" + "github.com/crlssn/getstronger/server/gen/orm" ) type Registry struct { - handlers map[string]Handler + handlers map[orm.EventTopic]Handler } type RegistryParams struct { fx.In - UserFollowed *UserFollowed + FollowedUser *FollowedUser RequestTraced *RequestTraced WorkoutCommentPosted *WorkoutCommentPosted } func NewRegistry(p RegistryParams) *Registry { return &Registry{ - handlers: map[string]Handler{ - events.UserFollowed: p.UserFollowed, - events.RequestTraced: p.RequestTraced, - events.WorkoutCommentPosted: p.WorkoutCommentPosted, + handlers: map[orm.EventTopic]Handler{ + orm.EventTopicFollowedUser: p.FollowedUser, + orm.EventTopicRequestTraced: p.RequestTraced, + orm.EventTopicWorkoutCommentPosted: p.WorkoutCommentPosted, }, } } -func (r *Registry) Handlers() map[string]Handler { +func (r *Registry) Handlers() map[orm.EventTopic]Handler { return r.handlers } diff --git a/server/pubsub/module.go b/server/pubsub/module.go index ec8a0e13..9f8f11cc 100644 --- a/server/pubsub/module.go +++ b/server/pubsub/module.go @@ -2,7 +2,6 @@ package pubsub import ( "context" - "fmt" "go.uber.org/fx" @@ -14,7 +13,7 @@ func Module() fx.Option { fx.Provide( New, handlers.NewRegistry, - handlers.NewUserFollowed, + handlers.NewFollowedUser, handlers.NewRequestTraced, handlers.NewWorkoutCommentPosted, ), @@ -22,16 +21,10 @@ func Module() fx.Option { func(lc fx.Lifecycle, pubSub *PubSub, registry *handlers.Registry) { lc.Append(fx.Hook{ OnStart: func(_ context.Context) error { - for event, handler := range registry.Handlers() { - if err := pubSub.Subscribe(event, handler); err != nil { - return fmt.Errorf("failed to subscribe to event %s: %w", event, err) - } - } - return nil + return pubSub.Subscribe(registry.Handlers()) }, OnStop: func(_ context.Context) error { - pubSub.Stop() - return nil + return pubSub.Stop() }, }) }, diff --git a/server/pubsub/payloads/payloads.go b/server/pubsub/payloads/payloads.go index 4f4b4134..845a2ac7 100644 --- a/server/pubsub/payloads/payloads.go +++ b/server/pubsub/payloads/payloads.go @@ -1,16 +1,16 @@ package payloads type RequestTraced struct { - Request string - DurationMS int - StatusCode int + Request string `json:"request"` + DurationMS int `json:"durationMs"` + StatusCode int `json:"statusCode"` } type WorkoutCommentPosted struct { - CommentID string + CommentID string `json:"commentId"` } type UserFollowed struct { - FollowerID string - FolloweeID string + FollowerID string `json:"followerId"` + FolloweeID string `json:"followeeId"` } diff --git a/server/pubsub/pubsub.go b/server/pubsub/pubsub.go index 0f522ec3..7307187e 100644 --- a/server/pubsub/pubsub.go +++ b/server/pubsub/pubsub.go @@ -1,91 +1,105 @@ package pubsub import ( + "context" + "encoding/json" "fmt" "sync" + "github.com/lib/pq" + "go.uber.org/fx" "go.uber.org/zap" + "github.com/crlssn/getstronger/server/gen/orm" "github.com/crlssn/getstronger/server/pubsub/handlers" + "github.com/crlssn/getstronger/server/repo" ) type PubSub struct { mu sync.RWMutex log *zap.Logger - channels map[string]chan any - handlers map[string]handlers.Handler + repo repo.Repo + listener *pq.Listener + handlers map[orm.EventTopic]handlers.Handler } -func New(log *zap.Logger) *PubSub { +type Params struct { + fx.In + + Log *zap.Logger + Repo repo.Repo + Listener *pq.Listener +} + +func New(p Params) *PubSub { return &PubSub{ - log: log, - channels: make(map[string]chan any), - handlers: make(map[string]handlers.Handler), + log: p.Log, + repo: p.Repo, + listener: p.Listener, + handlers: make(map[orm.EventTopic]handlers.Handler), } } -func (ps *PubSub) Publish(event string, payload any) { - ps.mu.RLock() - channel, found := ps.channels[event] - ps.mu.RUnlock() - - if !found { - ps.log.Error("channel not found", zap.String("event", event)) +func (ps *PubSub) Publish(ctx context.Context, topic orm.EventTopic, payload any) { + p, err := json.Marshal(payload) + if err != nil { + ps.log.Error("failed to marshal payload", zap.Error(err)) return } - channel <- payload + if err = ps.repo.PublishEvent(ctx, topic, p); err != nil { + ps.log.Error("failed to publish event", zap.Error(err)) + return + } } -const ( - channelWorkers = 5 - channelCapacity = 50 -) - -var errHandlerExists = fmt.Errorf("handler already exists") +const workers = 10 -func (ps *PubSub) Subscribe(event string, handler handlers.Handler) error { - ps.mu.Lock() - defer ps.mu.Unlock() - - if _, exists := ps.handlers[event]; exists { - return fmt.Errorf("%w: %s", errHandlerExists, event) +func (ps *PubSub) Subscribe(handlers map[orm.EventTopic]handlers.Handler) error { + for topic, handler := range handlers { + ps.handlers[topic] = handler + if err := ps.listener.Listen(topic.String()); err != nil { + return fmt.Errorf("failed to listen to event: %w", err) + } + ps.log.Info("subscribed to topic", zap.String("topic", topic.String())) } - ps.handlers[event] = handler - if _, found := ps.channels[event]; !found { - ps.channels[event] = make(chan any, channelCapacity) - for range channelWorkers { - go ps.startWorker(event) - } - ps.log.Info("subscribed to event", zap.String("event", event)) + for range workers { + go ps.startWorker() } return nil } -func (ps *PubSub) startWorker(event string) { - for payload := range ps.channels[event] { +func (ps *PubSub) startWorker() { + for event := range ps.listener.Notify { + if event == nil { + ps.log.Warn("listener disconnected") + return + } + + log := ps.log.With(zap.String("topic", event.Channel)) + log.Info("received event") + ps.mu.RLock() - handler := ps.handlers[event] + handler, ok := ps.handlers[orm.EventTopic(event.Channel)] ps.mu.RUnlock() - go func(payload any) { - defer func() { - if r := recover(); r != nil { - ps.log.Error("handler panicked", zap.Any("recover", r)) - } - }() - handler.HandlePayload(payload) - }(payload) + if !ok { + log.Error("handler not found") + continue + } + + go handler.HandlePayload(event.Extra) } } -func (ps *PubSub) Stop() { - ps.mu.Lock() - defer ps.mu.Unlock() - - for _, channel := range ps.channels { - close(channel) +func (ps *PubSub) Stop() error { + if err := ps.listener.UnlistenAll(); err != nil { + return fmt.Errorf("failed to unlisten: %w", err) } + if err := ps.listener.Close(); err != nil { + return fmt.Errorf("failed to close listener: %w", err) + } + return nil } diff --git a/server/pubsub/pubsub_test.go b/server/pubsub/pubsub_test.go new file mode 100644 index 00000000..c2c89605 --- /dev/null +++ b/server/pubsub/pubsub_test.go @@ -0,0 +1,117 @@ +package pubsub_test + +import ( + "context" + "encoding/json" + "sync" + "testing" + "time" + + "github.com/google/uuid" + "github.com/lib/pq" + "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" + "go.uber.org/zap" + + "github.com/crlssn/getstronger/server/gen/orm" + "github.com/crlssn/getstronger/server/pubsub" + "github.com/crlssn/getstronger/server/pubsub/handlers" + mock_handlers "github.com/crlssn/getstronger/server/pubsub/handlers/mocks" + "github.com/crlssn/getstronger/server/pubsub/payloads" + "github.com/crlssn/getstronger/server/repo" + "github.com/crlssn/getstronger/server/testing/container" +) + +type pubSubSuite struct { + suite.Suite + + pubSub *pubsub.PubSub + + mocks struct { + handler *mock_handlers.MockHandler + controller *gomock.Controller + } +} + +func TestPubSubSuite(t *testing.T) { + t.Parallel() + suite.Run(t, new(pubSubSuite)) +} + +func (s *pubSubSuite) SetupSuite() { + ctx := context.Background() + c := container.NewContainer(ctx) + + s.pubSub = pubsub.New(pubsub.Params{ + Log: zap.NewExample(), + Repo: repo.New(c.DB), + Listener: pq.NewListener(c.Connection, time.Second, time.Minute, nil), + }) + + s.mocks.controller = gomock.NewController(s.T()) + s.mocks.handler = mock_handlers.NewMockHandler(s.mocks.controller) + + err := s.pubSub.Subscribe(map[orm.EventTopic]handlers.Handler{ + orm.EventTopicFollowedUser: s.mocks.handler, + }) + s.Require().NoError(err) + + s.T().Cleanup(func() { + s.mocks.controller.Finish() + if err = c.Terminate(ctx); err != nil { + s.T().Fatalf("failed to clean container: %s", err) + } + }) +} + +func (s *pubSubSuite) TestPublish() { + type test struct { + name string + topic orm.EventTopic + payload any + init func(test) + } + + var wg sync.WaitGroup + + tests := []test{ + { + name: "ok_handler_found", + topic: orm.EventTopicFollowedUser, + payload: payloads.UserFollowed{ + FollowerID: uuid.NewString(), + FolloweeID: uuid.NewString(), + }, + init: func(t test) { + payload, err := json.Marshal(t.payload) + s.Require().NoError(err) + + wg.Add(1) + s.mocks.handler.EXPECT().HandlePayload(string(payload)).Do(func(_ string) { + wg.Done() + }) + }, + }, + { + name: "ok_handler_not_found", + topic: orm.EventTopicRequestTraced, + payload: payloads.WorkoutCommentPosted{ + CommentID: uuid.NewString(), + }, + init: func(t test) { + payload, err := json.Marshal(t.payload) + s.Require().NoError(err) + + s.mocks.handler.EXPECT().HandlePayload(string(payload)).Times(0) + }, + }, + } + + for _, t := range tests { + s.Run(t.name, func() { + t.init(t) + s.pubSub.Publish(context.Background(), t.topic, t.payload) + wg.Wait() + }) + } +} diff --git a/server/repo/interfaces.go b/server/repo/interfaces.go index 10970571..4fbf6724 100644 --- a/server/repo/interfaces.go +++ b/server/repo/interfaces.go @@ -7,6 +7,7 @@ import ( "github.com/crlssn/getstronger/server/gen/orm" ) +//go:generate mockgen -package mock_repo -source=interfaces.go -destination=mocks/mock_repo.go Repo type Repo interface { methods NewTx(ctx context.Context, f func(tx Tx) error) error @@ -22,6 +23,7 @@ type methods interface { authMethods userMethods traceMethods + pubSubMethods routineMethods workoutMethods exerciseMethods @@ -93,3 +95,7 @@ type notificationMethods interface { CountNotifications(ctx context.Context, opts ...CountNotificationsOpt) (int64, error) MarkNotificationsAsRead(ctx context.Context, userID string) error } + +type pubSubMethods interface { + PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error +} diff --git a/server/repo/mocks/mock_repo.go b/server/repo/mocks/mock_repo.go new file mode 100644 index 00000000..ca87ca2b --- /dev/null +++ b/server/repo/mocks/mock_repo.go @@ -0,0 +1,3292 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: interfaces.go +// +// Generated by this command: +// +// mockgen -package mock_repo -source=interfaces.go -destination=mocks/mock_repo.go Repo +// + +// Package mock_repo is a generated GoMock package. +package mock_repo + +import ( + context "context" + sql "database/sql" + reflect "reflect" + + orm "github.com/crlssn/getstronger/server/gen/orm" + repo "github.com/crlssn/getstronger/server/repo" + gomock "go.uber.org/mock/gomock" +) + +// MockRepo is a mock of Repo interface. +type MockRepo struct { + ctrl *gomock.Controller + recorder *MockRepoMockRecorder +} + +// MockRepoMockRecorder is the mock recorder for MockRepo. +type MockRepoMockRecorder struct { + mock *MockRepo +} + +// NewMockRepo creates a new mock instance. +func NewMockRepo(ctrl *gomock.Controller) *MockRepo { + mock := &MockRepo{ctrl: ctrl} + mock.recorder = &MockRepoMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRepo) EXPECT() *MockRepoMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockRepo) ISGOMOCK() struct{} { + return struct{}{} +} + +// AddExerciseToRoutine mocks base method. +func (m *MockRepo) AddExerciseToRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddExerciseToRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddExerciseToRoutine indicates an expected call of AddExerciseToRoutine. +func (mr *MockRepoMockRecorder) AddExerciseToRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddExerciseToRoutine", reflect.TypeOf((*MockRepo)(nil).AddExerciseToRoutine), ctx, exercise, routine) +} + +// CompareEmailAndPassword mocks base method. +func (m *MockRepo) CompareEmailAndPassword(ctx context.Context, email, password string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CompareEmailAndPassword", ctx, email, password) + ret0, _ := ret[0].(error) + return ret0 +} + +// CompareEmailAndPassword indicates an expected call of CompareEmailAndPassword. +func (mr *MockRepoMockRecorder) CompareEmailAndPassword(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareEmailAndPassword", reflect.TypeOf((*MockRepo)(nil).CompareEmailAndPassword), ctx, email, password) +} + +// CountNotifications mocks base method. +func (m *MockRepo) CountNotifications(ctx context.Context, opts ...repo.CountNotificationsOpt) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountNotifications", varargs...) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountNotifications indicates an expected call of CountNotifications. +func (mr *MockRepoMockRecorder) CountNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountNotifications", reflect.TypeOf((*MockRepo)(nil).CountNotifications), varargs...) +} + +// CreateAuth mocks base method. +func (m *MockRepo) CreateAuth(ctx context.Context, email, password string) (*orm.Auth, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateAuth", ctx, email, password) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateAuth indicates an expected call of CreateAuth. +func (mr *MockRepoMockRecorder) CreateAuth(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuth", reflect.TypeOf((*MockRepo)(nil).CreateAuth), ctx, email, password) +} + +// CreateExercise mocks base method. +func (m *MockRepo) CreateExercise(ctx context.Context, p repo.CreateExerciseParams) (*orm.Exercise, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateExercise", ctx, p) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateExercise indicates an expected call of CreateExercise. +func (mr *MockRepoMockRecorder) CreateExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateExercise", reflect.TypeOf((*MockRepo)(nil).CreateExercise), ctx, p) +} + +// CreateNotification mocks base method. +func (m *MockRepo) CreateNotification(ctx context.Context, p repo.CreateNotificationParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateNotification", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateNotification indicates an expected call of CreateNotification. +func (mr *MockRepoMockRecorder) CreateNotification(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNotification", reflect.TypeOf((*MockRepo)(nil).CreateNotification), ctx, p) +} + +// CreateRoutine mocks base method. +func (m *MockRepo) CreateRoutine(ctx context.Context, p repo.CreateRoutineParams) (*orm.Routine, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateRoutine", ctx, p) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateRoutine indicates an expected call of CreateRoutine. +func (mr *MockRepoMockRecorder) CreateRoutine(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRoutine", reflect.TypeOf((*MockRepo)(nil).CreateRoutine), ctx, p) +} + +// CreateUser mocks base method. +func (m *MockRepo) CreateUser(ctx context.Context, p repo.CreateUserParams) (*orm.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", ctx, p) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockRepoMockRecorder) CreateUser(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockRepo)(nil).CreateUser), ctx, p) +} + +// CreateWorkout mocks base method. +func (m *MockRepo) CreateWorkout(ctx context.Context, p repo.CreateWorkoutParams) (*orm.Workout, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkout", ctx, p) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkout indicates an expected call of CreateWorkout. +func (mr *MockRepoMockRecorder) CreateWorkout(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkout", reflect.TypeOf((*MockRepo)(nil).CreateWorkout), ctx, p) +} + +// CreateWorkoutComment mocks base method. +func (m *MockRepo) CreateWorkoutComment(ctx context.Context, p repo.CreateWorkoutCommentParams) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkoutComment", ctx, p) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkoutComment indicates an expected call of CreateWorkoutComment. +func (mr *MockRepoMockRecorder) CreateWorkoutComment(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkoutComment", reflect.TypeOf((*MockRepo)(nil).CreateWorkoutComment), ctx, p) +} + +// DeleteRoutine mocks base method. +func (m *MockRepo) DeleteRoutine(ctx context.Context, routineID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteRoutine", ctx, routineID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRoutine indicates an expected call of DeleteRoutine. +func (mr *MockRepoMockRecorder) DeleteRoutine(ctx, routineID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRoutine", reflect.TypeOf((*MockRepo)(nil).DeleteRoutine), ctx, routineID) +} + +// DeleteWorkout mocks base method. +func (m *MockRepo) DeleteWorkout(ctx context.Context, opts ...repo.DeleteWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWorkout indicates an expected call of DeleteWorkout. +func (mr *MockRepoMockRecorder) DeleteWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWorkout", reflect.TypeOf((*MockRepo)(nil).DeleteWorkout), varargs...) +} + +// Follow mocks base method. +func (m *MockRepo) Follow(ctx context.Context, p repo.FollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Follow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Follow indicates an expected call of Follow. +func (mr *MockRepoMockRecorder) Follow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Follow", reflect.TypeOf((*MockRepo)(nil).Follow), ctx, p) +} + +// GetAuth mocks base method. +func (m *MockRepo) GetAuth(ctx context.Context, opts ...repo.GetAuthOpt) (*orm.Auth, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetAuth", varargs...) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAuth indicates an expected call of GetAuth. +func (mr *MockRepoMockRecorder) GetAuth(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuth", reflect.TypeOf((*MockRepo)(nil).GetAuth), varargs...) +} + +// GetExercise mocks base method. +func (m *MockRepo) GetExercise(ctx context.Context, opts ...repo.GetExerciseOpt) (*orm.Exercise, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetExercise", varargs...) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExercise indicates an expected call of GetExercise. +func (mr *MockRepoMockRecorder) GetExercise(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExercise", reflect.TypeOf((*MockRepo)(nil).GetExercise), varargs...) +} + +// GetPersonalBests mocks base method. +func (m *MockRepo) GetPersonalBests(ctx context.Context, userID string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPersonalBests", ctx, userID) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPersonalBests indicates an expected call of GetPersonalBests. +func (mr *MockRepoMockRecorder) GetPersonalBests(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPersonalBests", reflect.TypeOf((*MockRepo)(nil).GetPersonalBests), ctx, userID) +} + +// GetPreviousWorkoutSets mocks base method. +func (m *MockRepo) GetPreviousWorkoutSets(ctx context.Context, exerciseIDs []string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPreviousWorkoutSets", ctx, exerciseIDs) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPreviousWorkoutSets indicates an expected call of GetPreviousWorkoutSets. +func (mr *MockRepoMockRecorder) GetPreviousWorkoutSets(ctx, exerciseIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPreviousWorkoutSets", reflect.TypeOf((*MockRepo)(nil).GetPreviousWorkoutSets), ctx, exerciseIDs) +} + +// GetRoutine mocks base method. +func (m *MockRepo) GetRoutine(ctx context.Context, opts ...repo.GetRoutineOpt) (*orm.Routine, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetRoutine", varargs...) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRoutine indicates an expected call of GetRoutine. +func (mr *MockRepoMockRecorder) GetRoutine(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRoutine", reflect.TypeOf((*MockRepo)(nil).GetRoutine), varargs...) +} + +// GetUser mocks base method. +func (m *MockRepo) GetUser(ctx context.Context, opts ...repo.GetUserOpt) (*orm.User, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetUser", varargs...) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockRepoMockRecorder) GetUser(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockRepo)(nil).GetUser), varargs...) +} + +// GetWorkout mocks base method. +func (m *MockRepo) GetWorkout(ctx context.Context, opts ...repo.GetWorkoutOpt) (*orm.Workout, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkout", varargs...) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkout indicates an expected call of GetWorkout. +func (mr *MockRepoMockRecorder) GetWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkout", reflect.TypeOf((*MockRepo)(nil).GetWorkout), varargs...) +} + +// GetWorkoutComment mocks base method. +func (m *MockRepo) GetWorkoutComment(ctx context.Context, opts ...repo.GetWorkoutCommentOpt) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkoutComment", varargs...) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkoutComment indicates an expected call of GetWorkoutComment. +func (mr *MockRepoMockRecorder) GetWorkoutComment(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkoutComment", reflect.TypeOf((*MockRepo)(nil).GetWorkoutComment), varargs...) +} + +// IsUserFollowedByUserID mocks base method. +func (m *MockRepo) IsUserFollowedByUserID(ctx context.Context, user *orm.User, userID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUserFollowedByUserID", ctx, user, userID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsUserFollowedByUserID indicates an expected call of IsUserFollowedByUserID. +func (mr *MockRepoMockRecorder) IsUserFollowedByUserID(ctx, user, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUserFollowedByUserID", reflect.TypeOf((*MockRepo)(nil).IsUserFollowedByUserID), ctx, user, userID) +} + +// ListExercises mocks base method. +func (m *MockRepo) ListExercises(ctx context.Context, opts ...repo.ListExercisesOpt) (orm.ExerciseSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListExercises", varargs...) + ret0, _ := ret[0].(orm.ExerciseSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListExercises indicates an expected call of ListExercises. +func (mr *MockRepoMockRecorder) ListExercises(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExercises", reflect.TypeOf((*MockRepo)(nil).ListExercises), varargs...) +} + +// ListFollowees mocks base method. +func (m *MockRepo) ListFollowees(ctx context.Context, userID string, opts ...repo.ListFolloweesOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowees", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowees indicates an expected call of ListFollowees. +func (mr *MockRepoMockRecorder) ListFollowees(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowees", reflect.TypeOf((*MockRepo)(nil).ListFollowees), varargs...) +} + +// ListFollowers mocks base method. +func (m *MockRepo) ListFollowers(ctx context.Context, userID string, opts ...repo.ListFollowersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowers indicates an expected call of ListFollowers. +func (mr *MockRepoMockRecorder) ListFollowers(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowers", reflect.TypeOf((*MockRepo)(nil).ListFollowers), varargs...) +} + +// ListNotifications mocks base method. +func (m *MockRepo) ListNotifications(ctx context.Context, opts ...repo.ListNotificationsOpt) (orm.NotificationSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListNotifications", varargs...) + ret0, _ := ret[0].(orm.NotificationSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListNotifications indicates an expected call of ListNotifications. +func (mr *MockRepoMockRecorder) ListNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNotifications", reflect.TypeOf((*MockRepo)(nil).ListNotifications), varargs...) +} + +// ListRoutines mocks base method. +func (m *MockRepo) ListRoutines(ctx context.Context, opts ...repo.ListRoutineOpt) (orm.RoutineSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRoutines", varargs...) + ret0, _ := ret[0].(orm.RoutineSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRoutines indicates an expected call of ListRoutines. +func (mr *MockRepoMockRecorder) ListRoutines(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRoutines", reflect.TypeOf((*MockRepo)(nil).ListRoutines), varargs...) +} + +// ListSets mocks base method. +func (m *MockRepo) ListSets(ctx context.Context, opts ...repo.ListSetsOpt) (orm.SetSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListSets", varargs...) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSets indicates an expected call of ListSets. +func (mr *MockRepoMockRecorder) ListSets(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSets", reflect.TypeOf((*MockRepo)(nil).ListSets), varargs...) +} + +// ListUsers mocks base method. +func (m *MockRepo) ListUsers(ctx context.Context, opts ...repo.ListUsersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListUsers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListUsers indicates an expected call of ListUsers. +func (mr *MockRepoMockRecorder) ListUsers(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUsers", reflect.TypeOf((*MockRepo)(nil).ListUsers), varargs...) +} + +// ListWorkouts mocks base method. +func (m *MockRepo) ListWorkouts(ctx context.Context, opts ...repo.ListWorkoutsOpt) (orm.WorkoutSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWorkouts", varargs...) + ret0, _ := ret[0].(orm.WorkoutSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWorkouts indicates an expected call of ListWorkouts. +func (mr *MockRepoMockRecorder) ListWorkouts(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWorkouts", reflect.TypeOf((*MockRepo)(nil).ListWorkouts), varargs...) +} + +// MarkNotificationsAsRead mocks base method. +func (m *MockRepo) MarkNotificationsAsRead(ctx context.Context, userID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MarkNotificationsAsRead", ctx, userID) + ret0, _ := ret[0].(error) + return ret0 +} + +// MarkNotificationsAsRead indicates an expected call of MarkNotificationsAsRead. +func (mr *MockRepoMockRecorder) MarkNotificationsAsRead(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkNotificationsAsRead", reflect.TypeOf((*MockRepo)(nil).MarkNotificationsAsRead), ctx, userID) +} + +// NewTx mocks base method. +func (m *MockRepo) NewTx(ctx context.Context, f func(repo.Tx) error) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewTx", ctx, f) + ret0, _ := ret[0].(error) + return ret0 +} + +// NewTx indicates an expected call of NewTx. +func (mr *MockRepoMockRecorder) NewTx(ctx, f any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewTx", reflect.TypeOf((*MockRepo)(nil).NewTx), ctx, f) +} + +// PublishEvent mocks base method. +func (m *MockRepo) PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishEvent", ctx, topic, payload) + ret0, _ := ret[0].(error) + return ret0 +} + +// PublishEvent indicates an expected call of PublishEvent. +func (mr *MockRepoMockRecorder) PublishEvent(ctx, topic, payload any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishEvent", reflect.TypeOf((*MockRepo)(nil).PublishEvent), ctx, topic, payload) +} + +// RefreshTokenExists mocks base method. +func (m *MockRepo) RefreshTokenExists(ctx context.Context, refreshToken string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RefreshTokenExists", ctx, refreshToken) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RefreshTokenExists indicates an expected call of RefreshTokenExists. +func (mr *MockRepoMockRecorder) RefreshTokenExists(ctx, refreshToken any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshTokenExists", reflect.TypeOf((*MockRepo)(nil).RefreshTokenExists), ctx, refreshToken) +} + +// RemoveExerciseFromRoutine mocks base method. +func (m *MockRepo) RemoveExerciseFromRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveExerciseFromRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveExerciseFromRoutine indicates an expected call of RemoveExerciseFromRoutine. +func (mr *MockRepoMockRecorder) RemoveExerciseFromRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveExerciseFromRoutine", reflect.TypeOf((*MockRepo)(nil).RemoveExerciseFromRoutine), ctx, exercise, routine) +} + +// SetRoutineExercises mocks base method. +func (m *MockRepo) SetRoutineExercises(ctx context.Context, routine *orm.Routine, exercises orm.ExerciseSlice) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRoutineExercises", ctx, routine, exercises) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRoutineExercises indicates an expected call of SetRoutineExercises. +func (mr *MockRepoMockRecorder) SetRoutineExercises(ctx, routine, exercises any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRoutineExercises", reflect.TypeOf((*MockRepo)(nil).SetRoutineExercises), ctx, routine, exercises) +} + +// SoftDeleteExercise mocks base method. +func (m *MockRepo) SoftDeleteExercise(ctx context.Context, p repo.SoftDeleteExerciseParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SoftDeleteExercise", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// SoftDeleteExercise indicates an expected call of SoftDeleteExercise. +func (mr *MockRepoMockRecorder) SoftDeleteExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SoftDeleteExercise", reflect.TypeOf((*MockRepo)(nil).SoftDeleteExercise), ctx, p) +} + +// StoreTrace mocks base method. +func (m *MockRepo) StoreTrace(ctx context.Context, p repo.StoreTraceParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreTrace", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// StoreTrace indicates an expected call of StoreTrace. +func (mr *MockRepoMockRecorder) StoreTrace(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreTrace", reflect.TypeOf((*MockRepo)(nil).StoreTrace), ctx, p) +} + +// Unfollow mocks base method. +func (m *MockRepo) Unfollow(ctx context.Context, p repo.UnfollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unfollow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unfollow indicates an expected call of Unfollow. +func (mr *MockRepoMockRecorder) Unfollow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unfollow", reflect.TypeOf((*MockRepo)(nil).Unfollow), ctx, p) +} + +// UpdateAuth mocks base method. +func (m *MockRepo) UpdateAuth(ctx context.Context, authID string, opts ...repo.UpdateAuthOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, authID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateAuth", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateAuth indicates an expected call of UpdateAuth. +func (mr *MockRepoMockRecorder) UpdateAuth(ctx, authID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, authID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAuth", reflect.TypeOf((*MockRepo)(nil).UpdateAuth), varargs...) +} + +// UpdateExercise mocks base method. +func (m *MockRepo) UpdateExercise(ctx context.Context, exerciseID string, opts ...repo.UpdateExerciseOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, exerciseID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateExercise", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateExercise indicates an expected call of UpdateExercise. +func (mr *MockRepoMockRecorder) UpdateExercise(ctx, exerciseID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, exerciseID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExercise", reflect.TypeOf((*MockRepo)(nil).UpdateExercise), varargs...) +} + +// UpdateRoutine mocks base method. +func (m *MockRepo) UpdateRoutine(ctx context.Context, routineID string, opts ...repo.UpdateRoutineOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, routineID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRoutine", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRoutine indicates an expected call of UpdateRoutine. +func (mr *MockRepoMockRecorder) UpdateRoutine(ctx, routineID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, routineID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRoutine", reflect.TypeOf((*MockRepo)(nil).UpdateRoutine), varargs...) +} + +// UpdateWorkout mocks base method. +func (m *MockRepo) UpdateWorkout(ctx context.Context, workoutID string, opts ...repo.UpdateWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, workoutID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkout indicates an expected call of UpdateWorkout. +func (mr *MockRepoMockRecorder) UpdateWorkout(ctx, workoutID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, workoutID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkout", reflect.TypeOf((*MockRepo)(nil).UpdateWorkout), varargs...) +} + +// UpdateWorkoutSets mocks base method. +func (m *MockRepo) UpdateWorkoutSets(ctx context.Context, workoutID string, exerciseSets []repo.ExerciseSet) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateWorkoutSets", ctx, workoutID, exerciseSets) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkoutSets indicates an expected call of UpdateWorkoutSets. +func (mr *MockRepoMockRecorder) UpdateWorkoutSets(ctx, workoutID, exerciseSets any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkoutSets", reflect.TypeOf((*MockRepo)(nil).UpdateWorkoutSets), ctx, workoutID, exerciseSets) +} + +// MockTx is a mock of Tx interface. +type MockTx struct { + ctrl *gomock.Controller + recorder *MockTxMockRecorder +} + +// MockTxMockRecorder is the mock recorder for MockTx. +type MockTxMockRecorder struct { + mock *MockTx +} + +// NewMockTx creates a new mock instance. +func NewMockTx(ctrl *gomock.Controller) *MockTx { + mock := &MockTx{ctrl: ctrl} + mock.recorder = &MockTxMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTx) EXPECT() *MockTxMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockTx) ISGOMOCK() struct{} { + return struct{}{} +} + +// AddExerciseToRoutine mocks base method. +func (m *MockTx) AddExerciseToRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddExerciseToRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddExerciseToRoutine indicates an expected call of AddExerciseToRoutine. +func (mr *MockTxMockRecorder) AddExerciseToRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddExerciseToRoutine", reflect.TypeOf((*MockTx)(nil).AddExerciseToRoutine), ctx, exercise, routine) +} + +// CompareEmailAndPassword mocks base method. +func (m *MockTx) CompareEmailAndPassword(ctx context.Context, email, password string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CompareEmailAndPassword", ctx, email, password) + ret0, _ := ret[0].(error) + return ret0 +} + +// CompareEmailAndPassword indicates an expected call of CompareEmailAndPassword. +func (mr *MockTxMockRecorder) CompareEmailAndPassword(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareEmailAndPassword", reflect.TypeOf((*MockTx)(nil).CompareEmailAndPassword), ctx, email, password) +} + +// CountNotifications mocks base method. +func (m *MockTx) CountNotifications(ctx context.Context, opts ...repo.CountNotificationsOpt) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountNotifications", varargs...) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountNotifications indicates an expected call of CountNotifications. +func (mr *MockTxMockRecorder) CountNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountNotifications", reflect.TypeOf((*MockTx)(nil).CountNotifications), varargs...) +} + +// CreateAuth mocks base method. +func (m *MockTx) CreateAuth(ctx context.Context, email, password string) (*orm.Auth, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateAuth", ctx, email, password) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateAuth indicates an expected call of CreateAuth. +func (mr *MockTxMockRecorder) CreateAuth(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuth", reflect.TypeOf((*MockTx)(nil).CreateAuth), ctx, email, password) +} + +// CreateExercise mocks base method. +func (m *MockTx) CreateExercise(ctx context.Context, p repo.CreateExerciseParams) (*orm.Exercise, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateExercise", ctx, p) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateExercise indicates an expected call of CreateExercise. +func (mr *MockTxMockRecorder) CreateExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateExercise", reflect.TypeOf((*MockTx)(nil).CreateExercise), ctx, p) +} + +// CreateNotification mocks base method. +func (m *MockTx) CreateNotification(ctx context.Context, p repo.CreateNotificationParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateNotification", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateNotification indicates an expected call of CreateNotification. +func (mr *MockTxMockRecorder) CreateNotification(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNotification", reflect.TypeOf((*MockTx)(nil).CreateNotification), ctx, p) +} + +// CreateRoutine mocks base method. +func (m *MockTx) CreateRoutine(ctx context.Context, p repo.CreateRoutineParams) (*orm.Routine, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateRoutine", ctx, p) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateRoutine indicates an expected call of CreateRoutine. +func (mr *MockTxMockRecorder) CreateRoutine(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRoutine", reflect.TypeOf((*MockTx)(nil).CreateRoutine), ctx, p) +} + +// CreateUser mocks base method. +func (m *MockTx) CreateUser(ctx context.Context, p repo.CreateUserParams) (*orm.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", ctx, p) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockTxMockRecorder) CreateUser(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockTx)(nil).CreateUser), ctx, p) +} + +// CreateWorkout mocks base method. +func (m *MockTx) CreateWorkout(ctx context.Context, p repo.CreateWorkoutParams) (*orm.Workout, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkout", ctx, p) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkout indicates an expected call of CreateWorkout. +func (mr *MockTxMockRecorder) CreateWorkout(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkout", reflect.TypeOf((*MockTx)(nil).CreateWorkout), ctx, p) +} + +// CreateWorkoutComment mocks base method. +func (m *MockTx) CreateWorkoutComment(ctx context.Context, p repo.CreateWorkoutCommentParams) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkoutComment", ctx, p) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkoutComment indicates an expected call of CreateWorkoutComment. +func (mr *MockTxMockRecorder) CreateWorkoutComment(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkoutComment", reflect.TypeOf((*MockTx)(nil).CreateWorkoutComment), ctx, p) +} + +// DeleteRoutine mocks base method. +func (m *MockTx) DeleteRoutine(ctx context.Context, routineID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteRoutine", ctx, routineID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRoutine indicates an expected call of DeleteRoutine. +func (mr *MockTxMockRecorder) DeleteRoutine(ctx, routineID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRoutine", reflect.TypeOf((*MockTx)(nil).DeleteRoutine), ctx, routineID) +} + +// DeleteWorkout mocks base method. +func (m *MockTx) DeleteWorkout(ctx context.Context, opts ...repo.DeleteWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWorkout indicates an expected call of DeleteWorkout. +func (mr *MockTxMockRecorder) DeleteWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWorkout", reflect.TypeOf((*MockTx)(nil).DeleteWorkout), varargs...) +} + +// Follow mocks base method. +func (m *MockTx) Follow(ctx context.Context, p repo.FollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Follow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Follow indicates an expected call of Follow. +func (mr *MockTxMockRecorder) Follow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Follow", reflect.TypeOf((*MockTx)(nil).Follow), ctx, p) +} + +// GetAuth mocks base method. +func (m *MockTx) GetAuth(ctx context.Context, opts ...repo.GetAuthOpt) (*orm.Auth, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetAuth", varargs...) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAuth indicates an expected call of GetAuth. +func (mr *MockTxMockRecorder) GetAuth(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuth", reflect.TypeOf((*MockTx)(nil).GetAuth), varargs...) +} + +// GetExercise mocks base method. +func (m *MockTx) GetExercise(ctx context.Context, opts ...repo.GetExerciseOpt) (*orm.Exercise, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetExercise", varargs...) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExercise indicates an expected call of GetExercise. +func (mr *MockTxMockRecorder) GetExercise(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExercise", reflect.TypeOf((*MockTx)(nil).GetExercise), varargs...) +} + +// GetPersonalBests mocks base method. +func (m *MockTx) GetPersonalBests(ctx context.Context, userID string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPersonalBests", ctx, userID) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPersonalBests indicates an expected call of GetPersonalBests. +func (mr *MockTxMockRecorder) GetPersonalBests(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPersonalBests", reflect.TypeOf((*MockTx)(nil).GetPersonalBests), ctx, userID) +} + +// GetPreviousWorkoutSets mocks base method. +func (m *MockTx) GetPreviousWorkoutSets(ctx context.Context, exerciseIDs []string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPreviousWorkoutSets", ctx, exerciseIDs) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPreviousWorkoutSets indicates an expected call of GetPreviousWorkoutSets. +func (mr *MockTxMockRecorder) GetPreviousWorkoutSets(ctx, exerciseIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPreviousWorkoutSets", reflect.TypeOf((*MockTx)(nil).GetPreviousWorkoutSets), ctx, exerciseIDs) +} + +// GetRoutine mocks base method. +func (m *MockTx) GetRoutine(ctx context.Context, opts ...repo.GetRoutineOpt) (*orm.Routine, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetRoutine", varargs...) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRoutine indicates an expected call of GetRoutine. +func (mr *MockTxMockRecorder) GetRoutine(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRoutine", reflect.TypeOf((*MockTx)(nil).GetRoutine), varargs...) +} + +// GetTx mocks base method. +func (m *MockTx) GetTx() *sql.Tx { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTx") + ret0, _ := ret[0].(*sql.Tx) + return ret0 +} + +// GetTx indicates an expected call of GetTx. +func (mr *MockTxMockRecorder) GetTx() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTx", reflect.TypeOf((*MockTx)(nil).GetTx)) +} + +// GetUser mocks base method. +func (m *MockTx) GetUser(ctx context.Context, opts ...repo.GetUserOpt) (*orm.User, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetUser", varargs...) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockTxMockRecorder) GetUser(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockTx)(nil).GetUser), varargs...) +} + +// GetWorkout mocks base method. +func (m *MockTx) GetWorkout(ctx context.Context, opts ...repo.GetWorkoutOpt) (*orm.Workout, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkout", varargs...) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkout indicates an expected call of GetWorkout. +func (mr *MockTxMockRecorder) GetWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkout", reflect.TypeOf((*MockTx)(nil).GetWorkout), varargs...) +} + +// GetWorkoutComment mocks base method. +func (m *MockTx) GetWorkoutComment(ctx context.Context, opts ...repo.GetWorkoutCommentOpt) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkoutComment", varargs...) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkoutComment indicates an expected call of GetWorkoutComment. +func (mr *MockTxMockRecorder) GetWorkoutComment(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkoutComment", reflect.TypeOf((*MockTx)(nil).GetWorkoutComment), varargs...) +} + +// IsUserFollowedByUserID mocks base method. +func (m *MockTx) IsUserFollowedByUserID(ctx context.Context, user *orm.User, userID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUserFollowedByUserID", ctx, user, userID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsUserFollowedByUserID indicates an expected call of IsUserFollowedByUserID. +func (mr *MockTxMockRecorder) IsUserFollowedByUserID(ctx, user, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUserFollowedByUserID", reflect.TypeOf((*MockTx)(nil).IsUserFollowedByUserID), ctx, user, userID) +} + +// ListExercises mocks base method. +func (m *MockTx) ListExercises(ctx context.Context, opts ...repo.ListExercisesOpt) (orm.ExerciseSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListExercises", varargs...) + ret0, _ := ret[0].(orm.ExerciseSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListExercises indicates an expected call of ListExercises. +func (mr *MockTxMockRecorder) ListExercises(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExercises", reflect.TypeOf((*MockTx)(nil).ListExercises), varargs...) +} + +// ListFollowees mocks base method. +func (m *MockTx) ListFollowees(ctx context.Context, userID string, opts ...repo.ListFolloweesOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowees", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowees indicates an expected call of ListFollowees. +func (mr *MockTxMockRecorder) ListFollowees(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowees", reflect.TypeOf((*MockTx)(nil).ListFollowees), varargs...) +} + +// ListFollowers mocks base method. +func (m *MockTx) ListFollowers(ctx context.Context, userID string, opts ...repo.ListFollowersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowers indicates an expected call of ListFollowers. +func (mr *MockTxMockRecorder) ListFollowers(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowers", reflect.TypeOf((*MockTx)(nil).ListFollowers), varargs...) +} + +// ListNotifications mocks base method. +func (m *MockTx) ListNotifications(ctx context.Context, opts ...repo.ListNotificationsOpt) (orm.NotificationSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListNotifications", varargs...) + ret0, _ := ret[0].(orm.NotificationSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListNotifications indicates an expected call of ListNotifications. +func (mr *MockTxMockRecorder) ListNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNotifications", reflect.TypeOf((*MockTx)(nil).ListNotifications), varargs...) +} + +// ListRoutines mocks base method. +func (m *MockTx) ListRoutines(ctx context.Context, opts ...repo.ListRoutineOpt) (orm.RoutineSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRoutines", varargs...) + ret0, _ := ret[0].(orm.RoutineSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRoutines indicates an expected call of ListRoutines. +func (mr *MockTxMockRecorder) ListRoutines(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRoutines", reflect.TypeOf((*MockTx)(nil).ListRoutines), varargs...) +} + +// ListSets mocks base method. +func (m *MockTx) ListSets(ctx context.Context, opts ...repo.ListSetsOpt) (orm.SetSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListSets", varargs...) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSets indicates an expected call of ListSets. +func (mr *MockTxMockRecorder) ListSets(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSets", reflect.TypeOf((*MockTx)(nil).ListSets), varargs...) +} + +// ListUsers mocks base method. +func (m *MockTx) ListUsers(ctx context.Context, opts ...repo.ListUsersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListUsers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListUsers indicates an expected call of ListUsers. +func (mr *MockTxMockRecorder) ListUsers(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUsers", reflect.TypeOf((*MockTx)(nil).ListUsers), varargs...) +} + +// ListWorkouts mocks base method. +func (m *MockTx) ListWorkouts(ctx context.Context, opts ...repo.ListWorkoutsOpt) (orm.WorkoutSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWorkouts", varargs...) + ret0, _ := ret[0].(orm.WorkoutSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWorkouts indicates an expected call of ListWorkouts. +func (mr *MockTxMockRecorder) ListWorkouts(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWorkouts", reflect.TypeOf((*MockTx)(nil).ListWorkouts), varargs...) +} + +// MarkNotificationsAsRead mocks base method. +func (m *MockTx) MarkNotificationsAsRead(ctx context.Context, userID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MarkNotificationsAsRead", ctx, userID) + ret0, _ := ret[0].(error) + return ret0 +} + +// MarkNotificationsAsRead indicates an expected call of MarkNotificationsAsRead. +func (mr *MockTxMockRecorder) MarkNotificationsAsRead(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkNotificationsAsRead", reflect.TypeOf((*MockTx)(nil).MarkNotificationsAsRead), ctx, userID) +} + +// PublishEvent mocks base method. +func (m *MockTx) PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishEvent", ctx, topic, payload) + ret0, _ := ret[0].(error) + return ret0 +} + +// PublishEvent indicates an expected call of PublishEvent. +func (mr *MockTxMockRecorder) PublishEvent(ctx, topic, payload any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishEvent", reflect.TypeOf((*MockTx)(nil).PublishEvent), ctx, topic, payload) +} + +// RefreshTokenExists mocks base method. +func (m *MockTx) RefreshTokenExists(ctx context.Context, refreshToken string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RefreshTokenExists", ctx, refreshToken) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RefreshTokenExists indicates an expected call of RefreshTokenExists. +func (mr *MockTxMockRecorder) RefreshTokenExists(ctx, refreshToken any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshTokenExists", reflect.TypeOf((*MockTx)(nil).RefreshTokenExists), ctx, refreshToken) +} + +// RemoveExerciseFromRoutine mocks base method. +func (m *MockTx) RemoveExerciseFromRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveExerciseFromRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveExerciseFromRoutine indicates an expected call of RemoveExerciseFromRoutine. +func (mr *MockTxMockRecorder) RemoveExerciseFromRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveExerciseFromRoutine", reflect.TypeOf((*MockTx)(nil).RemoveExerciseFromRoutine), ctx, exercise, routine) +} + +// SetRoutineExercises mocks base method. +func (m *MockTx) SetRoutineExercises(ctx context.Context, routine *orm.Routine, exercises orm.ExerciseSlice) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRoutineExercises", ctx, routine, exercises) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRoutineExercises indicates an expected call of SetRoutineExercises. +func (mr *MockTxMockRecorder) SetRoutineExercises(ctx, routine, exercises any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRoutineExercises", reflect.TypeOf((*MockTx)(nil).SetRoutineExercises), ctx, routine, exercises) +} + +// SoftDeleteExercise mocks base method. +func (m *MockTx) SoftDeleteExercise(ctx context.Context, p repo.SoftDeleteExerciseParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SoftDeleteExercise", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// SoftDeleteExercise indicates an expected call of SoftDeleteExercise. +func (mr *MockTxMockRecorder) SoftDeleteExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SoftDeleteExercise", reflect.TypeOf((*MockTx)(nil).SoftDeleteExercise), ctx, p) +} + +// StoreTrace mocks base method. +func (m *MockTx) StoreTrace(ctx context.Context, p repo.StoreTraceParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreTrace", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// StoreTrace indicates an expected call of StoreTrace. +func (mr *MockTxMockRecorder) StoreTrace(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreTrace", reflect.TypeOf((*MockTx)(nil).StoreTrace), ctx, p) +} + +// Unfollow mocks base method. +func (m *MockTx) Unfollow(ctx context.Context, p repo.UnfollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unfollow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unfollow indicates an expected call of Unfollow. +func (mr *MockTxMockRecorder) Unfollow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unfollow", reflect.TypeOf((*MockTx)(nil).Unfollow), ctx, p) +} + +// UpdateAuth mocks base method. +func (m *MockTx) UpdateAuth(ctx context.Context, authID string, opts ...repo.UpdateAuthOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, authID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateAuth", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateAuth indicates an expected call of UpdateAuth. +func (mr *MockTxMockRecorder) UpdateAuth(ctx, authID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, authID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAuth", reflect.TypeOf((*MockTx)(nil).UpdateAuth), varargs...) +} + +// UpdateExercise mocks base method. +func (m *MockTx) UpdateExercise(ctx context.Context, exerciseID string, opts ...repo.UpdateExerciseOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, exerciseID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateExercise", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateExercise indicates an expected call of UpdateExercise. +func (mr *MockTxMockRecorder) UpdateExercise(ctx, exerciseID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, exerciseID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExercise", reflect.TypeOf((*MockTx)(nil).UpdateExercise), varargs...) +} + +// UpdateRoutine mocks base method. +func (m *MockTx) UpdateRoutine(ctx context.Context, routineID string, opts ...repo.UpdateRoutineOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, routineID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRoutine", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRoutine indicates an expected call of UpdateRoutine. +func (mr *MockTxMockRecorder) UpdateRoutine(ctx, routineID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, routineID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRoutine", reflect.TypeOf((*MockTx)(nil).UpdateRoutine), varargs...) +} + +// UpdateWorkout mocks base method. +func (m *MockTx) UpdateWorkout(ctx context.Context, workoutID string, opts ...repo.UpdateWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, workoutID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkout indicates an expected call of UpdateWorkout. +func (mr *MockTxMockRecorder) UpdateWorkout(ctx, workoutID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, workoutID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkout", reflect.TypeOf((*MockTx)(nil).UpdateWorkout), varargs...) +} + +// UpdateWorkoutSets mocks base method. +func (m *MockTx) UpdateWorkoutSets(ctx context.Context, workoutID string, exerciseSets []repo.ExerciseSet) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateWorkoutSets", ctx, workoutID, exerciseSets) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkoutSets indicates an expected call of UpdateWorkoutSets. +func (mr *MockTxMockRecorder) UpdateWorkoutSets(ctx, workoutID, exerciseSets any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkoutSets", reflect.TypeOf((*MockTx)(nil).UpdateWorkoutSets), ctx, workoutID, exerciseSets) +} + +// Mockmethods is a mock of methods interface. +type Mockmethods struct { + ctrl *gomock.Controller + recorder *MockmethodsMockRecorder +} + +// MockmethodsMockRecorder is the mock recorder for Mockmethods. +type MockmethodsMockRecorder struct { + mock *Mockmethods +} + +// NewMockmethods creates a new mock instance. +func NewMockmethods(ctrl *gomock.Controller) *Mockmethods { + mock := &Mockmethods{ctrl: ctrl} + mock.recorder = &MockmethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *Mockmethods) EXPECT() *MockmethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *Mockmethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// AddExerciseToRoutine mocks base method. +func (m *Mockmethods) AddExerciseToRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddExerciseToRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddExerciseToRoutine indicates an expected call of AddExerciseToRoutine. +func (mr *MockmethodsMockRecorder) AddExerciseToRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddExerciseToRoutine", reflect.TypeOf((*Mockmethods)(nil).AddExerciseToRoutine), ctx, exercise, routine) +} + +// CompareEmailAndPassword mocks base method. +func (m *Mockmethods) CompareEmailAndPassword(ctx context.Context, email, password string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CompareEmailAndPassword", ctx, email, password) + ret0, _ := ret[0].(error) + return ret0 +} + +// CompareEmailAndPassword indicates an expected call of CompareEmailAndPassword. +func (mr *MockmethodsMockRecorder) CompareEmailAndPassword(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareEmailAndPassword", reflect.TypeOf((*Mockmethods)(nil).CompareEmailAndPassword), ctx, email, password) +} + +// CountNotifications mocks base method. +func (m *Mockmethods) CountNotifications(ctx context.Context, opts ...repo.CountNotificationsOpt) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountNotifications", varargs...) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountNotifications indicates an expected call of CountNotifications. +func (mr *MockmethodsMockRecorder) CountNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountNotifications", reflect.TypeOf((*Mockmethods)(nil).CountNotifications), varargs...) +} + +// CreateAuth mocks base method. +func (m *Mockmethods) CreateAuth(ctx context.Context, email, password string) (*orm.Auth, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateAuth", ctx, email, password) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateAuth indicates an expected call of CreateAuth. +func (mr *MockmethodsMockRecorder) CreateAuth(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuth", reflect.TypeOf((*Mockmethods)(nil).CreateAuth), ctx, email, password) +} + +// CreateExercise mocks base method. +func (m *Mockmethods) CreateExercise(ctx context.Context, p repo.CreateExerciseParams) (*orm.Exercise, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateExercise", ctx, p) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateExercise indicates an expected call of CreateExercise. +func (mr *MockmethodsMockRecorder) CreateExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateExercise", reflect.TypeOf((*Mockmethods)(nil).CreateExercise), ctx, p) +} + +// CreateNotification mocks base method. +func (m *Mockmethods) CreateNotification(ctx context.Context, p repo.CreateNotificationParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateNotification", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateNotification indicates an expected call of CreateNotification. +func (mr *MockmethodsMockRecorder) CreateNotification(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNotification", reflect.TypeOf((*Mockmethods)(nil).CreateNotification), ctx, p) +} + +// CreateRoutine mocks base method. +func (m *Mockmethods) CreateRoutine(ctx context.Context, p repo.CreateRoutineParams) (*orm.Routine, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateRoutine", ctx, p) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateRoutine indicates an expected call of CreateRoutine. +func (mr *MockmethodsMockRecorder) CreateRoutine(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRoutine", reflect.TypeOf((*Mockmethods)(nil).CreateRoutine), ctx, p) +} + +// CreateUser mocks base method. +func (m *Mockmethods) CreateUser(ctx context.Context, p repo.CreateUserParams) (*orm.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", ctx, p) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockmethodsMockRecorder) CreateUser(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*Mockmethods)(nil).CreateUser), ctx, p) +} + +// CreateWorkout mocks base method. +func (m *Mockmethods) CreateWorkout(ctx context.Context, p repo.CreateWorkoutParams) (*orm.Workout, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkout", ctx, p) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkout indicates an expected call of CreateWorkout. +func (mr *MockmethodsMockRecorder) CreateWorkout(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkout", reflect.TypeOf((*Mockmethods)(nil).CreateWorkout), ctx, p) +} + +// CreateWorkoutComment mocks base method. +func (m *Mockmethods) CreateWorkoutComment(ctx context.Context, p repo.CreateWorkoutCommentParams) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkoutComment", ctx, p) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkoutComment indicates an expected call of CreateWorkoutComment. +func (mr *MockmethodsMockRecorder) CreateWorkoutComment(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkoutComment", reflect.TypeOf((*Mockmethods)(nil).CreateWorkoutComment), ctx, p) +} + +// DeleteRoutine mocks base method. +func (m *Mockmethods) DeleteRoutine(ctx context.Context, routineID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteRoutine", ctx, routineID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRoutine indicates an expected call of DeleteRoutine. +func (mr *MockmethodsMockRecorder) DeleteRoutine(ctx, routineID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRoutine", reflect.TypeOf((*Mockmethods)(nil).DeleteRoutine), ctx, routineID) +} + +// DeleteWorkout mocks base method. +func (m *Mockmethods) DeleteWorkout(ctx context.Context, opts ...repo.DeleteWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWorkout indicates an expected call of DeleteWorkout. +func (mr *MockmethodsMockRecorder) DeleteWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWorkout", reflect.TypeOf((*Mockmethods)(nil).DeleteWorkout), varargs...) +} + +// Follow mocks base method. +func (m *Mockmethods) Follow(ctx context.Context, p repo.FollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Follow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Follow indicates an expected call of Follow. +func (mr *MockmethodsMockRecorder) Follow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Follow", reflect.TypeOf((*Mockmethods)(nil).Follow), ctx, p) +} + +// GetAuth mocks base method. +func (m *Mockmethods) GetAuth(ctx context.Context, opts ...repo.GetAuthOpt) (*orm.Auth, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetAuth", varargs...) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAuth indicates an expected call of GetAuth. +func (mr *MockmethodsMockRecorder) GetAuth(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuth", reflect.TypeOf((*Mockmethods)(nil).GetAuth), varargs...) +} + +// GetExercise mocks base method. +func (m *Mockmethods) GetExercise(ctx context.Context, opts ...repo.GetExerciseOpt) (*orm.Exercise, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetExercise", varargs...) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExercise indicates an expected call of GetExercise. +func (mr *MockmethodsMockRecorder) GetExercise(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExercise", reflect.TypeOf((*Mockmethods)(nil).GetExercise), varargs...) +} + +// GetPersonalBests mocks base method. +func (m *Mockmethods) GetPersonalBests(ctx context.Context, userID string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPersonalBests", ctx, userID) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPersonalBests indicates an expected call of GetPersonalBests. +func (mr *MockmethodsMockRecorder) GetPersonalBests(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPersonalBests", reflect.TypeOf((*Mockmethods)(nil).GetPersonalBests), ctx, userID) +} + +// GetPreviousWorkoutSets mocks base method. +func (m *Mockmethods) GetPreviousWorkoutSets(ctx context.Context, exerciseIDs []string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPreviousWorkoutSets", ctx, exerciseIDs) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPreviousWorkoutSets indicates an expected call of GetPreviousWorkoutSets. +func (mr *MockmethodsMockRecorder) GetPreviousWorkoutSets(ctx, exerciseIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPreviousWorkoutSets", reflect.TypeOf((*Mockmethods)(nil).GetPreviousWorkoutSets), ctx, exerciseIDs) +} + +// GetRoutine mocks base method. +func (m *Mockmethods) GetRoutine(ctx context.Context, opts ...repo.GetRoutineOpt) (*orm.Routine, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetRoutine", varargs...) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRoutine indicates an expected call of GetRoutine. +func (mr *MockmethodsMockRecorder) GetRoutine(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRoutine", reflect.TypeOf((*Mockmethods)(nil).GetRoutine), varargs...) +} + +// GetUser mocks base method. +func (m *Mockmethods) GetUser(ctx context.Context, opts ...repo.GetUserOpt) (*orm.User, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetUser", varargs...) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockmethodsMockRecorder) GetUser(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*Mockmethods)(nil).GetUser), varargs...) +} + +// GetWorkout mocks base method. +func (m *Mockmethods) GetWorkout(ctx context.Context, opts ...repo.GetWorkoutOpt) (*orm.Workout, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkout", varargs...) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkout indicates an expected call of GetWorkout. +func (mr *MockmethodsMockRecorder) GetWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkout", reflect.TypeOf((*Mockmethods)(nil).GetWorkout), varargs...) +} + +// GetWorkoutComment mocks base method. +func (m *Mockmethods) GetWorkoutComment(ctx context.Context, opts ...repo.GetWorkoutCommentOpt) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkoutComment", varargs...) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkoutComment indicates an expected call of GetWorkoutComment. +func (mr *MockmethodsMockRecorder) GetWorkoutComment(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkoutComment", reflect.TypeOf((*Mockmethods)(nil).GetWorkoutComment), varargs...) +} + +// IsUserFollowedByUserID mocks base method. +func (m *Mockmethods) IsUserFollowedByUserID(ctx context.Context, user *orm.User, userID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUserFollowedByUserID", ctx, user, userID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsUserFollowedByUserID indicates an expected call of IsUserFollowedByUserID. +func (mr *MockmethodsMockRecorder) IsUserFollowedByUserID(ctx, user, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUserFollowedByUserID", reflect.TypeOf((*Mockmethods)(nil).IsUserFollowedByUserID), ctx, user, userID) +} + +// ListExercises mocks base method. +func (m *Mockmethods) ListExercises(ctx context.Context, opts ...repo.ListExercisesOpt) (orm.ExerciseSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListExercises", varargs...) + ret0, _ := ret[0].(orm.ExerciseSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListExercises indicates an expected call of ListExercises. +func (mr *MockmethodsMockRecorder) ListExercises(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExercises", reflect.TypeOf((*Mockmethods)(nil).ListExercises), varargs...) +} + +// ListFollowees mocks base method. +func (m *Mockmethods) ListFollowees(ctx context.Context, userID string, opts ...repo.ListFolloweesOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowees", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowees indicates an expected call of ListFollowees. +func (mr *MockmethodsMockRecorder) ListFollowees(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowees", reflect.TypeOf((*Mockmethods)(nil).ListFollowees), varargs...) +} + +// ListFollowers mocks base method. +func (m *Mockmethods) ListFollowers(ctx context.Context, userID string, opts ...repo.ListFollowersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowers indicates an expected call of ListFollowers. +func (mr *MockmethodsMockRecorder) ListFollowers(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowers", reflect.TypeOf((*Mockmethods)(nil).ListFollowers), varargs...) +} + +// ListNotifications mocks base method. +func (m *Mockmethods) ListNotifications(ctx context.Context, opts ...repo.ListNotificationsOpt) (orm.NotificationSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListNotifications", varargs...) + ret0, _ := ret[0].(orm.NotificationSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListNotifications indicates an expected call of ListNotifications. +func (mr *MockmethodsMockRecorder) ListNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNotifications", reflect.TypeOf((*Mockmethods)(nil).ListNotifications), varargs...) +} + +// ListRoutines mocks base method. +func (m *Mockmethods) ListRoutines(ctx context.Context, opts ...repo.ListRoutineOpt) (orm.RoutineSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRoutines", varargs...) + ret0, _ := ret[0].(orm.RoutineSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRoutines indicates an expected call of ListRoutines. +func (mr *MockmethodsMockRecorder) ListRoutines(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRoutines", reflect.TypeOf((*Mockmethods)(nil).ListRoutines), varargs...) +} + +// ListSets mocks base method. +func (m *Mockmethods) ListSets(ctx context.Context, opts ...repo.ListSetsOpt) (orm.SetSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListSets", varargs...) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSets indicates an expected call of ListSets. +func (mr *MockmethodsMockRecorder) ListSets(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSets", reflect.TypeOf((*Mockmethods)(nil).ListSets), varargs...) +} + +// ListUsers mocks base method. +func (m *Mockmethods) ListUsers(ctx context.Context, opts ...repo.ListUsersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListUsers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListUsers indicates an expected call of ListUsers. +func (mr *MockmethodsMockRecorder) ListUsers(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUsers", reflect.TypeOf((*Mockmethods)(nil).ListUsers), varargs...) +} + +// ListWorkouts mocks base method. +func (m *Mockmethods) ListWorkouts(ctx context.Context, opts ...repo.ListWorkoutsOpt) (orm.WorkoutSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWorkouts", varargs...) + ret0, _ := ret[0].(orm.WorkoutSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWorkouts indicates an expected call of ListWorkouts. +func (mr *MockmethodsMockRecorder) ListWorkouts(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWorkouts", reflect.TypeOf((*Mockmethods)(nil).ListWorkouts), varargs...) +} + +// MarkNotificationsAsRead mocks base method. +func (m *Mockmethods) MarkNotificationsAsRead(ctx context.Context, userID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MarkNotificationsAsRead", ctx, userID) + ret0, _ := ret[0].(error) + return ret0 +} + +// MarkNotificationsAsRead indicates an expected call of MarkNotificationsAsRead. +func (mr *MockmethodsMockRecorder) MarkNotificationsAsRead(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkNotificationsAsRead", reflect.TypeOf((*Mockmethods)(nil).MarkNotificationsAsRead), ctx, userID) +} + +// PublishEvent mocks base method. +func (m *Mockmethods) PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishEvent", ctx, topic, payload) + ret0, _ := ret[0].(error) + return ret0 +} + +// PublishEvent indicates an expected call of PublishEvent. +func (mr *MockmethodsMockRecorder) PublishEvent(ctx, topic, payload any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishEvent", reflect.TypeOf((*Mockmethods)(nil).PublishEvent), ctx, topic, payload) +} + +// RefreshTokenExists mocks base method. +func (m *Mockmethods) RefreshTokenExists(ctx context.Context, refreshToken string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RefreshTokenExists", ctx, refreshToken) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RefreshTokenExists indicates an expected call of RefreshTokenExists. +func (mr *MockmethodsMockRecorder) RefreshTokenExists(ctx, refreshToken any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshTokenExists", reflect.TypeOf((*Mockmethods)(nil).RefreshTokenExists), ctx, refreshToken) +} + +// RemoveExerciseFromRoutine mocks base method. +func (m *Mockmethods) RemoveExerciseFromRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveExerciseFromRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveExerciseFromRoutine indicates an expected call of RemoveExerciseFromRoutine. +func (mr *MockmethodsMockRecorder) RemoveExerciseFromRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveExerciseFromRoutine", reflect.TypeOf((*Mockmethods)(nil).RemoveExerciseFromRoutine), ctx, exercise, routine) +} + +// SetRoutineExercises mocks base method. +func (m *Mockmethods) SetRoutineExercises(ctx context.Context, routine *orm.Routine, exercises orm.ExerciseSlice) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRoutineExercises", ctx, routine, exercises) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRoutineExercises indicates an expected call of SetRoutineExercises. +func (mr *MockmethodsMockRecorder) SetRoutineExercises(ctx, routine, exercises any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRoutineExercises", reflect.TypeOf((*Mockmethods)(nil).SetRoutineExercises), ctx, routine, exercises) +} + +// SoftDeleteExercise mocks base method. +func (m *Mockmethods) SoftDeleteExercise(ctx context.Context, p repo.SoftDeleteExerciseParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SoftDeleteExercise", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// SoftDeleteExercise indicates an expected call of SoftDeleteExercise. +func (mr *MockmethodsMockRecorder) SoftDeleteExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SoftDeleteExercise", reflect.TypeOf((*Mockmethods)(nil).SoftDeleteExercise), ctx, p) +} + +// StoreTrace mocks base method. +func (m *Mockmethods) StoreTrace(ctx context.Context, p repo.StoreTraceParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreTrace", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// StoreTrace indicates an expected call of StoreTrace. +func (mr *MockmethodsMockRecorder) StoreTrace(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreTrace", reflect.TypeOf((*Mockmethods)(nil).StoreTrace), ctx, p) +} + +// Unfollow mocks base method. +func (m *Mockmethods) Unfollow(ctx context.Context, p repo.UnfollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unfollow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unfollow indicates an expected call of Unfollow. +func (mr *MockmethodsMockRecorder) Unfollow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unfollow", reflect.TypeOf((*Mockmethods)(nil).Unfollow), ctx, p) +} + +// UpdateAuth mocks base method. +func (m *Mockmethods) UpdateAuth(ctx context.Context, authID string, opts ...repo.UpdateAuthOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, authID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateAuth", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateAuth indicates an expected call of UpdateAuth. +func (mr *MockmethodsMockRecorder) UpdateAuth(ctx, authID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, authID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAuth", reflect.TypeOf((*Mockmethods)(nil).UpdateAuth), varargs...) +} + +// UpdateExercise mocks base method. +func (m *Mockmethods) UpdateExercise(ctx context.Context, exerciseID string, opts ...repo.UpdateExerciseOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, exerciseID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateExercise", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateExercise indicates an expected call of UpdateExercise. +func (mr *MockmethodsMockRecorder) UpdateExercise(ctx, exerciseID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, exerciseID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExercise", reflect.TypeOf((*Mockmethods)(nil).UpdateExercise), varargs...) +} + +// UpdateRoutine mocks base method. +func (m *Mockmethods) UpdateRoutine(ctx context.Context, routineID string, opts ...repo.UpdateRoutineOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, routineID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRoutine", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRoutine indicates an expected call of UpdateRoutine. +func (mr *MockmethodsMockRecorder) UpdateRoutine(ctx, routineID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, routineID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRoutine", reflect.TypeOf((*Mockmethods)(nil).UpdateRoutine), varargs...) +} + +// UpdateWorkout mocks base method. +func (m *Mockmethods) UpdateWorkout(ctx context.Context, workoutID string, opts ...repo.UpdateWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, workoutID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkout indicates an expected call of UpdateWorkout. +func (mr *MockmethodsMockRecorder) UpdateWorkout(ctx, workoutID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, workoutID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkout", reflect.TypeOf((*Mockmethods)(nil).UpdateWorkout), varargs...) +} + +// UpdateWorkoutSets mocks base method. +func (m *Mockmethods) UpdateWorkoutSets(ctx context.Context, workoutID string, exerciseSets []repo.ExerciseSet) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateWorkoutSets", ctx, workoutID, exerciseSets) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkoutSets indicates an expected call of UpdateWorkoutSets. +func (mr *MockmethodsMockRecorder) UpdateWorkoutSets(ctx, workoutID, exerciseSets any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkoutSets", reflect.TypeOf((*Mockmethods)(nil).UpdateWorkoutSets), ctx, workoutID, exerciseSets) +} + +// MocksetMethods is a mock of setMethods interface. +type MocksetMethods struct { + ctrl *gomock.Controller + recorder *MocksetMethodsMockRecorder +} + +// MocksetMethodsMockRecorder is the mock recorder for MocksetMethods. +type MocksetMethodsMockRecorder struct { + mock *MocksetMethods +} + +// NewMocksetMethods creates a new mock instance. +func NewMocksetMethods(ctrl *gomock.Controller) *MocksetMethods { + mock := &MocksetMethods{ctrl: ctrl} + mock.recorder = &MocksetMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MocksetMethods) EXPECT() *MocksetMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MocksetMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// GetPersonalBests mocks base method. +func (m *MocksetMethods) GetPersonalBests(ctx context.Context, userID string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPersonalBests", ctx, userID) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPersonalBests indicates an expected call of GetPersonalBests. +func (mr *MocksetMethodsMockRecorder) GetPersonalBests(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPersonalBests", reflect.TypeOf((*MocksetMethods)(nil).GetPersonalBests), ctx, userID) +} + +// GetPreviousWorkoutSets mocks base method. +func (m *MocksetMethods) GetPreviousWorkoutSets(ctx context.Context, exerciseIDs []string) (orm.SetSlice, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPreviousWorkoutSets", ctx, exerciseIDs) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPreviousWorkoutSets indicates an expected call of GetPreviousWorkoutSets. +func (mr *MocksetMethodsMockRecorder) GetPreviousWorkoutSets(ctx, exerciseIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPreviousWorkoutSets", reflect.TypeOf((*MocksetMethods)(nil).GetPreviousWorkoutSets), ctx, exerciseIDs) +} + +// ListSets mocks base method. +func (m *MocksetMethods) ListSets(ctx context.Context, opts ...repo.ListSetsOpt) (orm.SetSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListSets", varargs...) + ret0, _ := ret[0].(orm.SetSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSets indicates an expected call of ListSets. +func (mr *MocksetMethodsMockRecorder) ListSets(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSets", reflect.TypeOf((*MocksetMethods)(nil).ListSets), varargs...) +} + +// MockauthMethods is a mock of authMethods interface. +type MockauthMethods struct { + ctrl *gomock.Controller + recorder *MockauthMethodsMockRecorder +} + +// MockauthMethodsMockRecorder is the mock recorder for MockauthMethods. +type MockauthMethodsMockRecorder struct { + mock *MockauthMethods +} + +// NewMockauthMethods creates a new mock instance. +func NewMockauthMethods(ctrl *gomock.Controller) *MockauthMethods { + mock := &MockauthMethods{ctrl: ctrl} + mock.recorder = &MockauthMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockauthMethods) EXPECT() *MockauthMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockauthMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// CompareEmailAndPassword mocks base method. +func (m *MockauthMethods) CompareEmailAndPassword(ctx context.Context, email, password string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CompareEmailAndPassword", ctx, email, password) + ret0, _ := ret[0].(error) + return ret0 +} + +// CompareEmailAndPassword indicates an expected call of CompareEmailAndPassword. +func (mr *MockauthMethodsMockRecorder) CompareEmailAndPassword(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareEmailAndPassword", reflect.TypeOf((*MockauthMethods)(nil).CompareEmailAndPassword), ctx, email, password) +} + +// CreateAuth mocks base method. +func (m *MockauthMethods) CreateAuth(ctx context.Context, email, password string) (*orm.Auth, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateAuth", ctx, email, password) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateAuth indicates an expected call of CreateAuth. +func (mr *MockauthMethodsMockRecorder) CreateAuth(ctx, email, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuth", reflect.TypeOf((*MockauthMethods)(nil).CreateAuth), ctx, email, password) +} + +// GetAuth mocks base method. +func (m *MockauthMethods) GetAuth(ctx context.Context, opts ...repo.GetAuthOpt) (*orm.Auth, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetAuth", varargs...) + ret0, _ := ret[0].(*orm.Auth) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAuth indicates an expected call of GetAuth. +func (mr *MockauthMethodsMockRecorder) GetAuth(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuth", reflect.TypeOf((*MockauthMethods)(nil).GetAuth), varargs...) +} + +// RefreshTokenExists mocks base method. +func (m *MockauthMethods) RefreshTokenExists(ctx context.Context, refreshToken string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RefreshTokenExists", ctx, refreshToken) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RefreshTokenExists indicates an expected call of RefreshTokenExists. +func (mr *MockauthMethodsMockRecorder) RefreshTokenExists(ctx, refreshToken any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshTokenExists", reflect.TypeOf((*MockauthMethods)(nil).RefreshTokenExists), ctx, refreshToken) +} + +// UpdateAuth mocks base method. +func (m *MockauthMethods) UpdateAuth(ctx context.Context, authID string, opts ...repo.UpdateAuthOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, authID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateAuth", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateAuth indicates an expected call of UpdateAuth. +func (mr *MockauthMethodsMockRecorder) UpdateAuth(ctx, authID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, authID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAuth", reflect.TypeOf((*MockauthMethods)(nil).UpdateAuth), varargs...) +} + +// MockuserMethods is a mock of userMethods interface. +type MockuserMethods struct { + ctrl *gomock.Controller + recorder *MockuserMethodsMockRecorder +} + +// MockuserMethodsMockRecorder is the mock recorder for MockuserMethods. +type MockuserMethodsMockRecorder struct { + mock *MockuserMethods +} + +// NewMockuserMethods creates a new mock instance. +func NewMockuserMethods(ctrl *gomock.Controller) *MockuserMethods { + mock := &MockuserMethods{ctrl: ctrl} + mock.recorder = &MockuserMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockuserMethods) EXPECT() *MockuserMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockuserMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// CreateUser mocks base method. +func (m *MockuserMethods) CreateUser(ctx context.Context, p repo.CreateUserParams) (*orm.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", ctx, p) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockuserMethodsMockRecorder) CreateUser(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockuserMethods)(nil).CreateUser), ctx, p) +} + +// Follow mocks base method. +func (m *MockuserMethods) Follow(ctx context.Context, p repo.FollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Follow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Follow indicates an expected call of Follow. +func (mr *MockuserMethodsMockRecorder) Follow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Follow", reflect.TypeOf((*MockuserMethods)(nil).Follow), ctx, p) +} + +// GetUser mocks base method. +func (m *MockuserMethods) GetUser(ctx context.Context, opts ...repo.GetUserOpt) (*orm.User, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetUser", varargs...) + ret0, _ := ret[0].(*orm.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockuserMethodsMockRecorder) GetUser(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockuserMethods)(nil).GetUser), varargs...) +} + +// IsUserFollowedByUserID mocks base method. +func (m *MockuserMethods) IsUserFollowedByUserID(ctx context.Context, user *orm.User, userID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUserFollowedByUserID", ctx, user, userID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsUserFollowedByUserID indicates an expected call of IsUserFollowedByUserID. +func (mr *MockuserMethodsMockRecorder) IsUserFollowedByUserID(ctx, user, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUserFollowedByUserID", reflect.TypeOf((*MockuserMethods)(nil).IsUserFollowedByUserID), ctx, user, userID) +} + +// ListFollowees mocks base method. +func (m *MockuserMethods) ListFollowees(ctx context.Context, userID string, opts ...repo.ListFolloweesOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowees", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowees indicates an expected call of ListFollowees. +func (mr *MockuserMethodsMockRecorder) ListFollowees(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowees", reflect.TypeOf((*MockuserMethods)(nil).ListFollowees), varargs...) +} + +// ListFollowers mocks base method. +func (m *MockuserMethods) ListFollowers(ctx context.Context, userID string, opts ...repo.ListFollowersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx, userID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListFollowers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListFollowers indicates an expected call of ListFollowers. +func (mr *MockuserMethodsMockRecorder) ListFollowers(ctx, userID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, userID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListFollowers", reflect.TypeOf((*MockuserMethods)(nil).ListFollowers), varargs...) +} + +// ListUsers mocks base method. +func (m *MockuserMethods) ListUsers(ctx context.Context, opts ...repo.ListUsersOpt) (orm.UserSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListUsers", varargs...) + ret0, _ := ret[0].(orm.UserSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListUsers indicates an expected call of ListUsers. +func (mr *MockuserMethodsMockRecorder) ListUsers(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUsers", reflect.TypeOf((*MockuserMethods)(nil).ListUsers), varargs...) +} + +// Unfollow mocks base method. +func (m *MockuserMethods) Unfollow(ctx context.Context, p repo.UnfollowParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unfollow", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unfollow indicates an expected call of Unfollow. +func (mr *MockuserMethodsMockRecorder) Unfollow(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unfollow", reflect.TypeOf((*MockuserMethods)(nil).Unfollow), ctx, p) +} + +// MocktraceMethods is a mock of traceMethods interface. +type MocktraceMethods struct { + ctrl *gomock.Controller + recorder *MocktraceMethodsMockRecorder +} + +// MocktraceMethodsMockRecorder is the mock recorder for MocktraceMethods. +type MocktraceMethodsMockRecorder struct { + mock *MocktraceMethods +} + +// NewMocktraceMethods creates a new mock instance. +func NewMocktraceMethods(ctrl *gomock.Controller) *MocktraceMethods { + mock := &MocktraceMethods{ctrl: ctrl} + mock.recorder = &MocktraceMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MocktraceMethods) EXPECT() *MocktraceMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MocktraceMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// StoreTrace mocks base method. +func (m *MocktraceMethods) StoreTrace(ctx context.Context, p repo.StoreTraceParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreTrace", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// StoreTrace indicates an expected call of StoreTrace. +func (mr *MocktraceMethodsMockRecorder) StoreTrace(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreTrace", reflect.TypeOf((*MocktraceMethods)(nil).StoreTrace), ctx, p) +} + +// MockroutineMethods is a mock of routineMethods interface. +type MockroutineMethods struct { + ctrl *gomock.Controller + recorder *MockroutineMethodsMockRecorder +} + +// MockroutineMethodsMockRecorder is the mock recorder for MockroutineMethods. +type MockroutineMethodsMockRecorder struct { + mock *MockroutineMethods +} + +// NewMockroutineMethods creates a new mock instance. +func NewMockroutineMethods(ctrl *gomock.Controller) *MockroutineMethods { + mock := &MockroutineMethods{ctrl: ctrl} + mock.recorder = &MockroutineMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockroutineMethods) EXPECT() *MockroutineMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockroutineMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// AddExerciseToRoutine mocks base method. +func (m *MockroutineMethods) AddExerciseToRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddExerciseToRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddExerciseToRoutine indicates an expected call of AddExerciseToRoutine. +func (mr *MockroutineMethodsMockRecorder) AddExerciseToRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddExerciseToRoutine", reflect.TypeOf((*MockroutineMethods)(nil).AddExerciseToRoutine), ctx, exercise, routine) +} + +// CreateRoutine mocks base method. +func (m *MockroutineMethods) CreateRoutine(ctx context.Context, p repo.CreateRoutineParams) (*orm.Routine, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateRoutine", ctx, p) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateRoutine indicates an expected call of CreateRoutine. +func (mr *MockroutineMethodsMockRecorder) CreateRoutine(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRoutine", reflect.TypeOf((*MockroutineMethods)(nil).CreateRoutine), ctx, p) +} + +// DeleteRoutine mocks base method. +func (m *MockroutineMethods) DeleteRoutine(ctx context.Context, routineID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteRoutine", ctx, routineID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteRoutine indicates an expected call of DeleteRoutine. +func (mr *MockroutineMethodsMockRecorder) DeleteRoutine(ctx, routineID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRoutine", reflect.TypeOf((*MockroutineMethods)(nil).DeleteRoutine), ctx, routineID) +} + +// GetRoutine mocks base method. +func (m *MockroutineMethods) GetRoutine(ctx context.Context, opts ...repo.GetRoutineOpt) (*orm.Routine, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetRoutine", varargs...) + ret0, _ := ret[0].(*orm.Routine) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRoutine indicates an expected call of GetRoutine. +func (mr *MockroutineMethodsMockRecorder) GetRoutine(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRoutine", reflect.TypeOf((*MockroutineMethods)(nil).GetRoutine), varargs...) +} + +// ListRoutines mocks base method. +func (m *MockroutineMethods) ListRoutines(ctx context.Context, opts ...repo.ListRoutineOpt) (orm.RoutineSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListRoutines", varargs...) + ret0, _ := ret[0].(orm.RoutineSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListRoutines indicates an expected call of ListRoutines. +func (mr *MockroutineMethodsMockRecorder) ListRoutines(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListRoutines", reflect.TypeOf((*MockroutineMethods)(nil).ListRoutines), varargs...) +} + +// RemoveExerciseFromRoutine mocks base method. +func (m *MockroutineMethods) RemoveExerciseFromRoutine(ctx context.Context, exercise *orm.Exercise, routine *orm.Routine) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveExerciseFromRoutine", ctx, exercise, routine) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveExerciseFromRoutine indicates an expected call of RemoveExerciseFromRoutine. +func (mr *MockroutineMethodsMockRecorder) RemoveExerciseFromRoutine(ctx, exercise, routine any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveExerciseFromRoutine", reflect.TypeOf((*MockroutineMethods)(nil).RemoveExerciseFromRoutine), ctx, exercise, routine) +} + +// SetRoutineExercises mocks base method. +func (m *MockroutineMethods) SetRoutineExercises(ctx context.Context, routine *orm.Routine, exercises orm.ExerciseSlice) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRoutineExercises", ctx, routine, exercises) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRoutineExercises indicates an expected call of SetRoutineExercises. +func (mr *MockroutineMethodsMockRecorder) SetRoutineExercises(ctx, routine, exercises any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRoutineExercises", reflect.TypeOf((*MockroutineMethods)(nil).SetRoutineExercises), ctx, routine, exercises) +} + +// UpdateRoutine mocks base method. +func (m *MockroutineMethods) UpdateRoutine(ctx context.Context, routineID string, opts ...repo.UpdateRoutineOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, routineID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateRoutine", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateRoutine indicates an expected call of UpdateRoutine. +func (mr *MockroutineMethodsMockRecorder) UpdateRoutine(ctx, routineID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, routineID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRoutine", reflect.TypeOf((*MockroutineMethods)(nil).UpdateRoutine), varargs...) +} + +// MockworkoutMethods is a mock of workoutMethods interface. +type MockworkoutMethods struct { + ctrl *gomock.Controller + recorder *MockworkoutMethodsMockRecorder +} + +// MockworkoutMethodsMockRecorder is the mock recorder for MockworkoutMethods. +type MockworkoutMethodsMockRecorder struct { + mock *MockworkoutMethods +} + +// NewMockworkoutMethods creates a new mock instance. +func NewMockworkoutMethods(ctrl *gomock.Controller) *MockworkoutMethods { + mock := &MockworkoutMethods{ctrl: ctrl} + mock.recorder = &MockworkoutMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockworkoutMethods) EXPECT() *MockworkoutMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockworkoutMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// CreateWorkout mocks base method. +func (m *MockworkoutMethods) CreateWorkout(ctx context.Context, p repo.CreateWorkoutParams) (*orm.Workout, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkout", ctx, p) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkout indicates an expected call of CreateWorkout. +func (mr *MockworkoutMethodsMockRecorder) CreateWorkout(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkout", reflect.TypeOf((*MockworkoutMethods)(nil).CreateWorkout), ctx, p) +} + +// CreateWorkoutComment mocks base method. +func (m *MockworkoutMethods) CreateWorkoutComment(ctx context.Context, p repo.CreateWorkoutCommentParams) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateWorkoutComment", ctx, p) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateWorkoutComment indicates an expected call of CreateWorkoutComment. +func (mr *MockworkoutMethodsMockRecorder) CreateWorkoutComment(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkoutComment", reflect.TypeOf((*MockworkoutMethods)(nil).CreateWorkoutComment), ctx, p) +} + +// DeleteWorkout mocks base method. +func (m *MockworkoutMethods) DeleteWorkout(ctx context.Context, opts ...repo.DeleteWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteWorkout indicates an expected call of DeleteWorkout. +func (mr *MockworkoutMethodsMockRecorder) DeleteWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteWorkout", reflect.TypeOf((*MockworkoutMethods)(nil).DeleteWorkout), varargs...) +} + +// GetWorkout mocks base method. +func (m *MockworkoutMethods) GetWorkout(ctx context.Context, opts ...repo.GetWorkoutOpt) (*orm.Workout, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkout", varargs...) + ret0, _ := ret[0].(*orm.Workout) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkout indicates an expected call of GetWorkout. +func (mr *MockworkoutMethodsMockRecorder) GetWorkout(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkout", reflect.TypeOf((*MockworkoutMethods)(nil).GetWorkout), varargs...) +} + +// GetWorkoutComment mocks base method. +func (m *MockworkoutMethods) GetWorkoutComment(ctx context.Context, opts ...repo.GetWorkoutCommentOpt) (*orm.WorkoutComment, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetWorkoutComment", varargs...) + ret0, _ := ret[0].(*orm.WorkoutComment) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetWorkoutComment indicates an expected call of GetWorkoutComment. +func (mr *MockworkoutMethodsMockRecorder) GetWorkoutComment(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkoutComment", reflect.TypeOf((*MockworkoutMethods)(nil).GetWorkoutComment), varargs...) +} + +// ListWorkouts mocks base method. +func (m *MockworkoutMethods) ListWorkouts(ctx context.Context, opts ...repo.ListWorkoutsOpt) (orm.WorkoutSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListWorkouts", varargs...) + ret0, _ := ret[0].(orm.WorkoutSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListWorkouts indicates an expected call of ListWorkouts. +func (mr *MockworkoutMethodsMockRecorder) ListWorkouts(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListWorkouts", reflect.TypeOf((*MockworkoutMethods)(nil).ListWorkouts), varargs...) +} + +// UpdateWorkout mocks base method. +func (m *MockworkoutMethods) UpdateWorkout(ctx context.Context, workoutID string, opts ...repo.UpdateWorkoutOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, workoutID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateWorkout", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkout indicates an expected call of UpdateWorkout. +func (mr *MockworkoutMethodsMockRecorder) UpdateWorkout(ctx, workoutID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, workoutID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkout", reflect.TypeOf((*MockworkoutMethods)(nil).UpdateWorkout), varargs...) +} + +// UpdateWorkoutSets mocks base method. +func (m *MockworkoutMethods) UpdateWorkoutSets(ctx context.Context, workoutID string, exerciseSets []repo.ExerciseSet) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateWorkoutSets", ctx, workoutID, exerciseSets) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateWorkoutSets indicates an expected call of UpdateWorkoutSets. +func (mr *MockworkoutMethodsMockRecorder) UpdateWorkoutSets(ctx, workoutID, exerciseSets any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkoutSets", reflect.TypeOf((*MockworkoutMethods)(nil).UpdateWorkoutSets), ctx, workoutID, exerciseSets) +} + +// MockexerciseMethods is a mock of exerciseMethods interface. +type MockexerciseMethods struct { + ctrl *gomock.Controller + recorder *MockexerciseMethodsMockRecorder +} + +// MockexerciseMethodsMockRecorder is the mock recorder for MockexerciseMethods. +type MockexerciseMethodsMockRecorder struct { + mock *MockexerciseMethods +} + +// NewMockexerciseMethods creates a new mock instance. +func NewMockexerciseMethods(ctrl *gomock.Controller) *MockexerciseMethods { + mock := &MockexerciseMethods{ctrl: ctrl} + mock.recorder = &MockexerciseMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockexerciseMethods) EXPECT() *MockexerciseMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockexerciseMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// CreateExercise mocks base method. +func (m *MockexerciseMethods) CreateExercise(ctx context.Context, p repo.CreateExerciseParams) (*orm.Exercise, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateExercise", ctx, p) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateExercise indicates an expected call of CreateExercise. +func (mr *MockexerciseMethodsMockRecorder) CreateExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateExercise", reflect.TypeOf((*MockexerciseMethods)(nil).CreateExercise), ctx, p) +} + +// GetExercise mocks base method. +func (m *MockexerciseMethods) GetExercise(ctx context.Context, opts ...repo.GetExerciseOpt) (*orm.Exercise, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetExercise", varargs...) + ret0, _ := ret[0].(*orm.Exercise) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetExercise indicates an expected call of GetExercise. +func (mr *MockexerciseMethodsMockRecorder) GetExercise(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExercise", reflect.TypeOf((*MockexerciseMethods)(nil).GetExercise), varargs...) +} + +// ListExercises mocks base method. +func (m *MockexerciseMethods) ListExercises(ctx context.Context, opts ...repo.ListExercisesOpt) (orm.ExerciseSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListExercises", varargs...) + ret0, _ := ret[0].(orm.ExerciseSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListExercises indicates an expected call of ListExercises. +func (mr *MockexerciseMethodsMockRecorder) ListExercises(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListExercises", reflect.TypeOf((*MockexerciseMethods)(nil).ListExercises), varargs...) +} + +// SoftDeleteExercise mocks base method. +func (m *MockexerciseMethods) SoftDeleteExercise(ctx context.Context, p repo.SoftDeleteExerciseParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SoftDeleteExercise", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// SoftDeleteExercise indicates an expected call of SoftDeleteExercise. +func (mr *MockexerciseMethodsMockRecorder) SoftDeleteExercise(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SoftDeleteExercise", reflect.TypeOf((*MockexerciseMethods)(nil).SoftDeleteExercise), ctx, p) +} + +// UpdateExercise mocks base method. +func (m *MockexerciseMethods) UpdateExercise(ctx context.Context, exerciseID string, opts ...repo.UpdateExerciseOpt) error { + m.ctrl.T.Helper() + varargs := []any{ctx, exerciseID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateExercise", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateExercise indicates an expected call of UpdateExercise. +func (mr *MockexerciseMethodsMockRecorder) UpdateExercise(ctx, exerciseID any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx, exerciseID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateExercise", reflect.TypeOf((*MockexerciseMethods)(nil).UpdateExercise), varargs...) +} + +// MocknotificationMethods is a mock of notificationMethods interface. +type MocknotificationMethods struct { + ctrl *gomock.Controller + recorder *MocknotificationMethodsMockRecorder +} + +// MocknotificationMethodsMockRecorder is the mock recorder for MocknotificationMethods. +type MocknotificationMethodsMockRecorder struct { + mock *MocknotificationMethods +} + +// NewMocknotificationMethods creates a new mock instance. +func NewMocknotificationMethods(ctrl *gomock.Controller) *MocknotificationMethods { + mock := &MocknotificationMethods{ctrl: ctrl} + mock.recorder = &MocknotificationMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MocknotificationMethods) EXPECT() *MocknotificationMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MocknotificationMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// CountNotifications mocks base method. +func (m *MocknotificationMethods) CountNotifications(ctx context.Context, opts ...repo.CountNotificationsOpt) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountNotifications", varargs...) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountNotifications indicates an expected call of CountNotifications. +func (mr *MocknotificationMethodsMockRecorder) CountNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountNotifications", reflect.TypeOf((*MocknotificationMethods)(nil).CountNotifications), varargs...) +} + +// CreateNotification mocks base method. +func (m *MocknotificationMethods) CreateNotification(ctx context.Context, p repo.CreateNotificationParams) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateNotification", ctx, p) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateNotification indicates an expected call of CreateNotification. +func (mr *MocknotificationMethodsMockRecorder) CreateNotification(ctx, p any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNotification", reflect.TypeOf((*MocknotificationMethods)(nil).CreateNotification), ctx, p) +} + +// ListNotifications mocks base method. +func (m *MocknotificationMethods) ListNotifications(ctx context.Context, opts ...repo.ListNotificationsOpt) (orm.NotificationSlice, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ListNotifications", varargs...) + ret0, _ := ret[0].(orm.NotificationSlice) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListNotifications indicates an expected call of ListNotifications. +func (mr *MocknotificationMethodsMockRecorder) ListNotifications(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNotifications", reflect.TypeOf((*MocknotificationMethods)(nil).ListNotifications), varargs...) +} + +// MarkNotificationsAsRead mocks base method. +func (m *MocknotificationMethods) MarkNotificationsAsRead(ctx context.Context, userID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MarkNotificationsAsRead", ctx, userID) + ret0, _ := ret[0].(error) + return ret0 +} + +// MarkNotificationsAsRead indicates an expected call of MarkNotificationsAsRead. +func (mr *MocknotificationMethodsMockRecorder) MarkNotificationsAsRead(ctx, userID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MarkNotificationsAsRead", reflect.TypeOf((*MocknotificationMethods)(nil).MarkNotificationsAsRead), ctx, userID) +} + +// MockpubSubMethods is a mock of pubSubMethods interface. +type MockpubSubMethods struct { + ctrl *gomock.Controller + recorder *MockpubSubMethodsMockRecorder +} + +// MockpubSubMethodsMockRecorder is the mock recorder for MockpubSubMethods. +type MockpubSubMethodsMockRecorder struct { + mock *MockpubSubMethods +} + +// NewMockpubSubMethods creates a new mock instance. +func NewMockpubSubMethods(ctrl *gomock.Controller) *MockpubSubMethods { + mock := &MockpubSubMethods{ctrl: ctrl} + mock.recorder = &MockpubSubMethodsMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockpubSubMethods) EXPECT() *MockpubSubMethodsMockRecorder { + return m.recorder +} + +// ISGOMOCK indicates that this struct is a gomock mock. +func (m *MockpubSubMethods) ISGOMOCK() struct{} { + return struct{}{} +} + +// PublishEvent mocks base method. +func (m *MockpubSubMethods) PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishEvent", ctx, topic, payload) + ret0, _ := ret[0].(error) + return ret0 +} + +// PublishEvent indicates an expected call of PublishEvent. +func (mr *MockpubSubMethodsMockRecorder) PublishEvent(ctx, topic, payload any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishEvent", reflect.TypeOf((*MockpubSubMethods)(nil).PublishEvent), ctx, topic, payload) +} diff --git a/server/repo/repo.go b/server/repo/repo.go index b8ee5cc9..16987d95 100644 --- a/server/repo/repo.go +++ b/server/repo/repo.go @@ -1425,3 +1425,34 @@ func (r *repo) UpdateWorkoutSets(ctx context.Context, workoutID string, exercise return nil }) } + +var ( + ErrEmptyPayload = fmt.Errorf("empty payload") + ErrInvalidTopic = fmt.Errorf("invalid topic") +) + +func (r *repo) PublishEvent(ctx context.Context, topic orm.EventTopic, payload []byte) error { + if topic.IsValid() != nil { + return fmt.Errorf("%w: %s", ErrInvalidTopic, topic) + } + + if len(payload) == 0 { + return ErrEmptyPayload + } + + return r.NewTx(ctx, func(tx Tx) error { + event := &orm.Event{ + Topic: topic, + Payload: payload, + } + if err := event.Insert(ctx, tx.GetTx(), boil.Infer()); err != nil { + return fmt.Errorf("event insert: %w", err) + } + + if _, err := tx.GetTx().Exec("SELECT pg_notify($1, $2)", topic.String(), payload); err != nil { + return fmt.Errorf("pg_notify: %w", err) + } + + return nil + }) +} diff --git a/server/repo/repo_test.go b/server/repo/repo_test.go index 74629732..9c9d298d 100644 --- a/server/repo/repo_test.go +++ b/server/repo/repo_test.go @@ -13,6 +13,7 @@ import ( "github.com/brianvoe/gofakeit/v7" "github.com/google/uuid" + "github.com/lib/pq" "github.com/stretchr/testify/suite" "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/queries/qm" @@ -1068,3 +1069,72 @@ func (s *repoSuite) TestDeleteWorkout() { }) } } + +func (s *repoSuite) TestPublishEvent() { + type expected struct { + err error + } + + type test struct { + name string + topic orm.EventTopic + payload []byte + expected expected + } + + tests := []test{ + { + name: "ok_publish_event_with_notify", + topic: orm.EventTopicWorkoutCommentPosted, + payload: []byte("{}"), + expected: expected{ + err: nil, + }, + }, + { + name: "err_invalid_topic", + topic: orm.EventTopic("not_found"), + payload: nil, + expected: expected{ + err: repo.ErrInvalidTopic, + }, + }, + { + name: "err_empty_payload", + topic: orm.EventTopicWorkoutCommentPosted, + payload: nil, + expected: expected{ + err: repo.ErrEmptyPayload, + }, + }, + } + + for _, t := range tests { + s.Run(t.name, func() { + var listener *pq.Listener + if t.topic.IsValid() == nil { + listener = pq.NewListener(s.testContainer.Connection, time.Second, time.Minute, nil) + s.Require().NoError(listener.Listen(t.topic.String())) + } + + err := s.repo.PublishEvent(context.Background(), t.topic, t.payload) + if t.expected.err != nil { + s.Require().Error(err) + s.Require().ErrorIs(err, t.expected.err) + return + } + s.Require().NoError(err) + + notification := <-listener.Notify + s.Require().Equal(t.topic.String(), notification.Channel) + s.Require().Equal(string(t.payload), notification.Extra) + + exists, err := orm.Events( + orm.EventWhere.Topic.EQ(t.topic), + orm.EventWhere.Payload.EQ(t.payload), + ).Exists(context.Background(), s.testContainer.DB) + s.Require().NoError(err) + s.Require().True(exists) + }) + } +} diff --git a/server/rpc/handlers/v1/user.go b/server/rpc/handlers/v1/user.go index 6257105b..456da5e4 100644 --- a/server/rpc/handlers/v1/user.go +++ b/server/rpc/handlers/v1/user.go @@ -11,7 +11,6 @@ import ( apiv1 "github.com/crlssn/getstronger/server/gen/proto/api/v1" "github.com/crlssn/getstronger/server/gen/proto/api/v1/apiv1connect" "github.com/crlssn/getstronger/server/pubsub" - "github.com/crlssn/getstronger/server/pubsub/events" "github.com/crlssn/getstronger/server/pubsub/payloads" "github.com/crlssn/getstronger/server/repo" "github.com/crlssn/getstronger/server/xcontext" @@ -98,7 +97,7 @@ func (h *userHandler) FollowUser(ctx context.Context, req *connect.Request[apiv1 return nil, connect.NewError(connect.CodeInternal, nil) } - h.pubSub.Publish(events.UserFollowed, &payloads.UserFollowed{ + h.pubSub.Publish(ctx, orm.EventTopicFollowedUser, payloads.UserFollowed{ FollowerID: userID, FolloweeID: req.Msg.GetFollowId(), }) diff --git a/server/rpc/handlers/v1/workout.go b/server/rpc/handlers/v1/workout.go index 29dd7bb5..259fc849 100644 --- a/server/rpc/handlers/v1/workout.go +++ b/server/rpc/handlers/v1/workout.go @@ -14,7 +14,6 @@ import ( apiv1 "github.com/crlssn/getstronger/server/gen/proto/api/v1" "github.com/crlssn/getstronger/server/gen/proto/api/v1/apiv1connect" "github.com/crlssn/getstronger/server/pubsub" - "github.com/crlssn/getstronger/server/pubsub/events" "github.com/crlssn/getstronger/server/pubsub/payloads" "github.com/crlssn/getstronger/server/repo" "github.com/crlssn/getstronger/server/xcontext" @@ -227,7 +226,7 @@ func (h *workoutHandler) PostComment(ctx context.Context, req *connect.Request[a return nil, connect.NewError(connect.CodeInternal, nil) } - h.pubSub.Publish(events.WorkoutCommentPosted, &payloads.WorkoutCommentPosted{ + h.pubSub.Publish(ctx, orm.EventTopicWorkoutCommentPosted, payloads.WorkoutCommentPosted{ CommentID: comment.ID, }) diff --git a/server/rpc/middlewares/middlewares.go b/server/rpc/middlewares/middlewares.go index 0e9e4555..8bbcd452 100644 --- a/server/rpc/middlewares/middlewares.go +++ b/server/rpc/middlewares/middlewares.go @@ -80,7 +80,7 @@ func (m *Middleware) trace(h http.Handler) http.Handler { // Use a custom response writer to capture the status code. rw := &trace.ResponseWriter{ResponseWriter: w} - t := m.tracer.Trace(r.RequestURI) + t := m.tracer.Trace(r.Context(), r.RequestURI) defer t.End(rw) h.ServeHTTP(rw, r) diff --git a/server/testing/container/container.go b/server/testing/container/container.go index 6aea6b75..204c359c 100644 --- a/server/testing/container/container.go +++ b/server/testing/container/container.go @@ -16,8 +16,9 @@ import ( ) type Container struct { - DB *sql.DB - Terminate func(ctx context.Context) error + DB *sql.DB + Terminate func(ctx context.Context) error + Connection string } const ( @@ -50,8 +51,9 @@ func NewContainer(ctx context.Context) *Container { } return &Container{ - DB: db, - Terminate: container.Terminate, + DB: db, + Terminate: container.Terminate, + Connection: connection, } } diff --git a/server/testing/container/module.go b/server/testing/container/module.go index 1e390103..d52dcaa0 100644 --- a/server/testing/container/module.go +++ b/server/testing/container/module.go @@ -3,7 +3,9 @@ package container import ( "context" "database/sql" + "time" + "github.com/lib/pq" "go.uber.org/fx" ) @@ -15,6 +17,9 @@ func Module() fx.Option { func(c *Container) *sql.DB { return c.DB }, + func(c *Container) *pq.Listener { + return pq.NewListener(c.Connection, time.Second, time.Minute, nil) + }, ), fx.Invoke(func(l fx.Lifecycle, c *Container) { l.Append(fx.Hook{ diff --git a/server/testing/factory/workout.go b/server/testing/factory/workout.go index a468207b..ca251dc8 100644 --- a/server/testing/factory/workout.go +++ b/server/testing/factory/workout.go @@ -53,20 +53,20 @@ func WorkoutUserID(userID string) WorkoutOpt { } } -type WorkoutCommentOpt func(comment *orm.WorkoutComment) - -func WorkoutCommentUserID(userID string) WorkoutCommentOpt { - return func(comment *orm.WorkoutComment) { - comment.UserID = userID +func WorkoutName(name string) WorkoutOpt { + return func(workout *orm.Workout) { + workout.Name = name } } -func WorkoutCommentWorkoutID(workoutID string) WorkoutCommentOpt { - return func(comment *orm.WorkoutComment) { - comment.WorkoutID = workoutID +func WorkoutCreatedAt(createdAt time.Time) WorkoutOpt { + return func(workout *orm.Workout) { + workout.CreatedAt = createdAt } } +type WorkoutCommentOpt func(comment *orm.WorkoutComment) + func (f *Factory) NewWorkoutComment(opts ...WorkoutCommentOpt) *orm.WorkoutComment { m := &orm.WorkoutComment{ ID: uuid.NewString(), @@ -97,14 +97,20 @@ func (f *Factory) NewWorkoutComment(opts ...WorkoutCommentOpt) *orm.WorkoutComme return m } -func WorkoutName(name string) WorkoutOpt { - return func(workout *orm.Workout) { - workout.Name = name +func WorkoutCommentID(id string) WorkoutCommentOpt { + return func(comment *orm.WorkoutComment) { + comment.ID = id } } -func WorkoutCreatedAt(createdAt time.Time) WorkoutOpt { - return func(workout *orm.Workout) { - workout.CreatedAt = createdAt +func WorkoutCommentUserID(userID string) WorkoutCommentOpt { + return func(comment *orm.WorkoutComment) { + comment.UserID = userID + } +} + +func WorkoutCommentWorkoutID(workoutID string) WorkoutCommentOpt { + return func(comment *orm.WorkoutComment) { + comment.WorkoutID = workoutID } } diff --git a/server/testing/factory/workout_test.go b/server/testing/factory/workout_test.go index 490141db..11a2e410 100644 --- a/server/testing/factory/workout_test.go +++ b/server/testing/factory/workout_test.go @@ -96,6 +96,15 @@ func TestFactory_WorkoutComment(t *testing.T) { require.Equal(t, expected.CreatedAt.Truncate(time.Millisecond), created.CreatedAt.Truncate(time.Millisecond)) }) + t.Run("WorkoutCommentID", func(t *testing.T) { + t.Parallel() + id := uuid.NewString() + expected := f.NewWorkoutComment(factory.WorkoutCommentID(id)) + created, err := orm.FindWorkoutComment(ctx, c.DB, expected.ID) + require.NoError(t, err) + require.Equal(t, id, created.ID) + }) + t.Run("WorkoutCommentUserID", func(t *testing.T) { t.Parallel() userID := f.NewUser().ID diff --git a/server/trace/trace.go b/server/trace/trace.go index d60c2f94..af407f6a 100644 --- a/server/trace/trace.go +++ b/server/trace/trace.go @@ -1,13 +1,14 @@ package trace import ( + "context" "net/http" "time" "go.uber.org/zap" + "github.com/crlssn/getstronger/server/gen/orm" "github.com/crlssn/getstronger/server/pubsub" - "github.com/crlssn/getstronger/server/pubsub/events" "github.com/crlssn/getstronger/server/pubsub/payloads" ) @@ -35,12 +36,12 @@ type Trace struct { onEnd func(duration time.Duration, statusCode int) } -func (m *Tracer) Trace(uri string) *Trace { +func (m *Tracer) Trace(ctx context.Context, uri string) *Trace { return &Trace{ start: time.Now().UTC(), onEnd: func(duration time.Duration, statusCode int) { m.log.Info("trace", zap.String("uri", uri), zap.Duration("duration", duration), zap.Int("status_code", statusCode)) - m.pubSub.Publish(events.RequestTraced, &payloads.RequestTraced{ + m.pubSub.Publish(ctx, orm.EventTopicRequestTraced, payloads.RequestTraced{ Request: uri, DurationMS: int(duration.Milliseconds()), StatusCode: statusCode,