mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-23 15:51:24 +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:
@@ -1,43 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/micro/services/streams/handler"
|
||||
pb "github.com/micro/services/streams/proto"
|
||||
|
||||
"github.com/micro/micro/v3/service"
|
||||
"github.com/micro/micro/v3/service/config"
|
||||
"github.com/micro/micro/v3/service/events"
|
||||
"github.com/micro/micro/v3/service/logger"
|
||||
"github.com/micro/services/pkg/cache"
|
||||
"github.com/micro/services/streams/handler"
|
||||
pb "github.com/micro/services/streams/proto"
|
||||
)
|
||||
|
||||
var dbAddress = "postgresql://postgres:postgres@localhost:5432/streams?sslmode=disable"
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := service.New(
|
||||
service.Name("streams"),
|
||||
service.Version("latest"),
|
||||
)
|
||||
|
||||
// Connect to the database
|
||||
cfg, err := config.Get("streams.database")
|
||||
if err != nil {
|
||||
logger.Fatalf("Error loading config: %v", err)
|
||||
}
|
||||
addr := cfg.String(dbAddress)
|
||||
sqlDB, err := sql.Open("pgx", addr)
|
||||
if err != nil {
|
||||
logger.Fatalf("Failed to open connection to DB %s", err)
|
||||
}
|
||||
|
||||
h := &handler.Streams{
|
||||
Cache: cache.DefaultCache,
|
||||
Events: events.DefaultStream,
|
||||
Time: time.Now,
|
||||
}
|
||||
h.DBConn(sqlDB).Migrations(&handler.Token{})
|
||||
|
||||
// Register handler
|
||||
pb.RegisterStreamsHandler(srv.Server(), h)
|
||||
|
||||
Reference in New Issue
Block a user