3
0

Added federation options to node service

This commit is contained in:
Peter Grlica
2020-11-13 14:16:41 +01:00
parent 4b50d3eddf
commit 85e615213d
4 changed files with 14 additions and 8 deletions

View File

@@ -4,6 +4,8 @@ import (
"context"
"crypto/tls"
"fmt"
"time"
cmpService "github.com/cortezaproject/corteza-server/compose/service"
cmpEvent "github.com/cortezaproject/corteza-server/compose/service/event"
fdrService "github.com/cortezaproject/corteza-server/federation/service"
@@ -30,7 +32,6 @@ import (
sysEvent "github.com/cortezaproject/corteza-server/system/service/event"
"go.uber.org/zap"
gomail "gopkg.in/mail.v2"
"time"
)
const (
@@ -244,7 +245,8 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
// Note: this is a legacy approach, all services from all 3 apps
// will most likely be merged in the future
err = fdrService.Initialize(ctx, app.Log, app.Store, fdrService.Config{
ActionLog: app.Opt.ActionLog,
ActionLog: app.Opt.ActionLog,
Federation: app.Opt.Federation,
})
if err != nil {

View File

@@ -12,6 +12,7 @@ import (
"github.com/cortezaproject/corteza-server/federation/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/options"
"github.com/cortezaproject/corteza-server/pkg/rand"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/service"
@@ -46,7 +47,7 @@ type (
}
)
func Node(s store.Storer, u service.UserService, al actionlog.Recorder, th auth.TokenHandler) *node {
func Node(s store.Storer, u service.UserService, al actionlog.Recorder, th auth.TokenHandler, options options.FederationOpt) *node {
return &node{
store: s,
sysUser: u,
@@ -58,7 +59,7 @@ func Node(s store.Storer, u service.UserService, al actionlog.Recorder, th auth.
name: "Server A",
// @todo read this from settings
host: "example.tld",
host: options.Host,
// @todo use HTTP_API_BASE_URL (HTTPServerOpt.ApiBaseUrl) to prefix URI path
baseURL: "/federation",

View File

@@ -22,8 +22,9 @@ import (
type (
Config struct {
ActionLog options.ActionLogOpt
Storage options.ObjectStoreOpt
ActionLog options.ActionLogOpt
Storage options.ObjectStoreOpt
Federation options.FederationOpt
}
)
@@ -122,7 +123,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s store.Storer, c Config)
hcd.Add(objstore.Healthcheck(DefaultObjectStore), "Store/Federation")
DefaultNode = Node(DefaultStore, service.DefaultUser, DefaultActionlog, auth.DefaultJwtHandler)
DefaultNode = Node(DefaultStore, service.DefaultUser, DefaultActionlog, auth.DefaultJwtHandler, c.Federation)
DefaultNodeSync = NodeSync()
DefaultExposedModule = ExposedModule()
DefaultSharedModule = SharedModule()

View File

@@ -2,7 +2,8 @@ package options
type (
FederationOpt struct {
Enabled bool `env:"FEDERATION_ENABLED"`
Enabled bool `env:"FEDERATION_ENABLED"`
Host string `env:"FEDERATION_HOST"`
}
)
@@ -10,6 +11,7 @@ func Federation() (o *FederationOpt) {
o = &FederationOpt{
Enabled: false,
Host: `example.tld`,
}
fill(o)