zitadel/internal/auth/repository/eventsourcing/view/view.go
Silvan 9271623ec9
fix: load auth users (#3907)
* fix: load auth users

* fix: add triggerbulk

* fix: build pre-release

* fix even more french translations

* fix: build version

Co-authored-by: Livio Spring <livio.a@gmail.com>
2022-07-07 14:58:00 +02:00

39 lines
915 B
Go

package view
import (
"database/sql"
"github.com/jinzhu/gorm"
"github.com/zitadel/zitadel/internal/crypto"
eventstore "github.com/zitadel/zitadel/internal/eventstore/v1"
"github.com/zitadel/zitadel/internal/id"
"github.com/zitadel/zitadel/internal/query"
)
type View struct {
Db *gorm.DB
keyAlgorithm crypto.EncryptionAlgorithm
idGenerator id.Generator
query *query.Queries
es eventstore.Eventstore
}
func StartView(sqlClient *sql.DB, keyAlgorithm crypto.EncryptionAlgorithm, queries *query.Queries, idGenerator id.Generator, es eventstore.Eventstore) (*View, error) {
gorm, err := gorm.Open("postgres", sqlClient)
if err != nil {
return nil, err
}
return &View{
Db: gorm,
keyAlgorithm: keyAlgorithm,
idGenerator: idGenerator,
query: queries,
es: es,
}, nil
}
func (v *View) Health() (err error) {
return v.Db.DB().Ping()
}