mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 05:55:19 +00:00
Streams tenancy (#91)
* fixup streams stuff * use cache instead of pg in streams * hash out issuer streams test * fix compile error
This commit is contained in:
@@ -7,8 +7,7 @@ import (
|
||||
"github.com/micro/micro/v3/service/auth"
|
||||
"github.com/micro/micro/v3/service/errors"
|
||||
"github.com/micro/micro/v3/service/events"
|
||||
gorm2 "github.com/micro/services/pkg/gorm"
|
||||
|
||||
"github.com/micro/services/pkg/cache"
|
||||
"github.com/nats-io/nats-streaming-server/util"
|
||||
)
|
||||
|
||||
@@ -24,18 +23,22 @@ var (
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
Token string `gorm:"primaryKey"`
|
||||
Token string
|
||||
Topic string
|
||||
Account string
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
type Streams struct {
|
||||
gorm2.Helper
|
||||
Cache cache.Cache
|
||||
Events events.Stream
|
||||
Time func() time.Time
|
||||
}
|
||||
|
||||
func (t *Token) Key() string {
|
||||
return fmt.Sprintf("%s:%s", t.Account, t.Token)
|
||||
}
|
||||
|
||||
func getAccount(acc *auth.Account) string {
|
||||
owner := acc.Metadata["apikey_owner"]
|
||||
if len(owner) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user