From 2a5ad833ebab5503d09bee2e32b5328712a8a0dc Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Sat, 24 Jul 2021 15:44:26 -0400 Subject: [PATCH] Add golangci-lint --- .github/workflows/test.yml | 2 ++ internal/domain/account.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 internal/domain/account.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d98683e..4fbb879 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,5 +14,7 @@ jobs: uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} + - name: Lint + uses: golangci/golangci-lint-action@v2 - name: Test run: go test ./... -v diff --git a/internal/domain/account.go b/internal/domain/account.go new file mode 100644 index 0000000..82ab2a6 --- /dev/null +++ b/internal/domain/account.go @@ -0,0 +1,37 @@ +package domain + +import "context" + +// Account represents an account we need to periodically check in the notifications worker. +type Account struct { + ID int64 + + // Reddit information + Username string + AccountID string + AccessToken string + RefreshToken string + ExpiresAt int64 + + // Tracking how far behind we are + LastMessageID string + LastCheckedAt float64 +} + +// AccountRepository represents the account's repository contract +type AccountRepository interface { + GetByID(ctx context.Context, id int64) (Account, error) + GetByRedditID(ctx context.Context, id string) (Account, error) + + Update(ctx context.Context, ac *Account) error + Create(ctx context.Context, ac *Account) error + Delete(ctx context.Context, id int64) error +} + +// AccountUsecase represents the account's usecases +type AccountUsecase interface { + GetByID(ctx context.Context, id int64) (Account, error) + GetByRedditID(ctx context.Context, id string) (Account, error) + CreateOrUpdate(ctx context.Context, ac *Account) error + Delete(ctx context.Context, id int64) error +}