-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e3c10e
commit 42b1a4c
Showing
11 changed files
with
213 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package adapters | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/zeiss/typhoon/internal/accounts/models" | ||
"github.com/zeiss/typhoon/internal/accounts/ports" | ||
|
||
"gorm.io/gorm" | ||
) | ||
|
||
var _ ports.Accounts = (*DB)(nil) | ||
|
||
// DB ... | ||
type DB struct { | ||
conn *gorm.DB | ||
} | ||
|
||
// NewDB ... | ||
func NewDB(conn *gorm.DB) *DB { | ||
return &DB{conn} | ||
} | ||
|
||
// GetToken ... | ||
func (db *DB) GetToken(ctx context.Context, account models.AccountPublicKey) (models.AccountToken, error) { | ||
return models.AccountToken(""), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package adapters | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/zeiss/typhoon/internal/accounts/controllers" | ||
"github.com/zeiss/typhoon/internal/accounts/models" | ||
) | ||
|
||
// AccountLookupRequestHandler ... | ||
type AccountLookupRequestHandler struct { | ||
ctrl controllers.AccountsController | ||
} | ||
|
||
// NewAccountLookupRequestHandler ... | ||
func NewAccountLookupRequestHandler(ctrl controllers.AccountsController) *AccountLookupRequestHandler { | ||
return &AccountLookupRequestHandler{ctrl: ctrl} | ||
} | ||
|
||
// HandleLookupRequest ... | ||
func (h *AccountLookupRequestHandler) HandleLookupRequest(ctx context.Context, accountPublicKey models.AccountPublicKey) (models.AccountToken, error) { | ||
return h.ctrl.GetToken(ctx, accountPublicKey) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/zeiss/typhoon/internal/accounts/models" | ||
"github.com/zeiss/typhoon/internal/accounts/ports" | ||
) | ||
|
||
// AccountsController ... | ||
type AccountsController interface { | ||
GetToken(ctx context.Context, accountPublicKey models.AccountPublicKey) (models.AccountToken, error) | ||
} | ||
|
||
// AccountsController ... | ||
type accountsController struct { | ||
db ports.Accounts | ||
} | ||
|
||
// NewAccountsController ... | ||
func NewAccountsController(db ports.Accounts) *accountsController { | ||
return &accountsController{db: db} | ||
} | ||
|
||
// GetToken ... | ||
func (c *accountsController) GetToken(ctx context.Context, pubkey models.AccountPublicKey) (models.AccountToken, error) { | ||
return c.db.GetToken(ctx, pubkey) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package models | ||
|
||
import "strings" | ||
|
||
// AccountPublicKey ... | ||
type AccountPublicKey string | ||
|
||
// String ... | ||
func (a AccountPublicKey) String() string { | ||
return strings.TrimSpace(string(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package models | ||
|
||
import "strings" | ||
|
||
// AccountToken ... | ||
type AccountToken string | ||
|
||
// String ... | ||
func (a AccountToken) String() string { | ||
return strings.TrimSpace(string(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ports | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/zeiss/typhoon/internal/accounts/models" | ||
) | ||
|
||
// Accounts ... | ||
type Accounts interface { | ||
// GetToken returns the token for the given account. | ||
GetToken(ctx context.Context, account models.AccountPublicKey) (models.AccountToken, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ports | ||
|
||
// Repositories ... | ||
type Repositories interface{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package services | ||
|
||
// LookupService ... | ||
type LookupService struct{} | ||
|
||
// NewLookupService ... | ||
func NewLookupService() *LookupService { | ||
return &LookupService{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters