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:
Asim Aslam
2021-05-01 22:34:35 +01:00
committed by GitHub
parent 500acefe47
commit b8877f8312
8 changed files with 87 additions and 82 deletions

View File

@@ -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 {