mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-24 00:28:18 +00:00
29 lines
480 B
Go
29 lines
480 B
Go
|
package view
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
"github.com/caos/zitadel/internal/id"
|
||
|
|
||
|
"github.com/jinzhu/gorm"
|
||
|
)
|
||
|
|
||
|
type View struct {
|
||
|
Db *gorm.DB
|
||
|
idGenerator id.Generator
|
||
|
}
|
||
|
|
||
|
func StartView(sqlClient *sql.DB, idGenerator id.Generator) (*View, error) {
|
||
|
gorm, err := gorm.Open("postgres", sqlClient)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &View{
|
||
|
Db: gorm,
|
||
|
idGenerator: idGenerator,
|
||
|
}, nil
|
||
|
}
|
||
|
|
||
|
func (v *View) Health() (err error) {
|
||
|
return v.Db.DB().Ping()
|
||
|
}
|