[full-ci] Events (#3146)

* initial events draft

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* start nats server with ocis

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* use feature reva and add config

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* remove unneeded files

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* edge reva and fix pipeline

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* configure nats server via ocis

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* update expected failures

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* add nats to parallel deployment

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* more expected failures

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* use NATS instead of cp SETTINGS

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* remove more configuration options

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
kobergj
2022-02-11 17:14:48 +01:00
committed by GitHub
parent d3585908b1
commit 889a42c964
20 changed files with 361 additions and 3 deletions
+18
View File
@@ -0,0 +1,18 @@
package command
import (
"github.com/owncloud/ocis/nats/pkg/config"
"github.com/urfave/cli/v2"
)
// Health is the entrypoint for the health command.
func Health(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "health",
Usage: "Check health status",
Action: func(c *cli.Context) error {
// Not implemented
return nil
},
}
}
+64
View File
@@ -0,0 +1,64 @@
package command
import (
"context"
"os"
"github.com/owncloud/ocis/nats/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the nats command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultApp(&cli.App{
Name: "nats",
Usage: "starts nats server",
Commands: GetCommands(cfg),
})
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Usage: "Show the help",
}
return app.Run(os.Args)
}
// SutureService allows for the nats command to be embedded and supervised by a suture supervisor tree.
type SutureService struct {
cfg *config.Config
}
// NewSutureService creates a new nats.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
cfg.Settings.Commons = cfg.Commons
return SutureService{
cfg: cfg.Nats,
}
}
func (s SutureService) Serve(ctx context.Context) error {
s.cfg.Context = ctx
if err := Execute(s.cfg); err != nil {
return err
}
return nil
}
+79
View File
@@ -0,0 +1,79 @@
package command
import (
"fmt"
"github.com/cs3org/reva/pkg/events/server"
"github.com/owncloud/ocis/nats/pkg/config"
"github.com/owncloud/ocis/nats/pkg/config/parser"
"github.com/owncloud/ocis/nats/pkg/logging"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/urfave/cli/v2"
// TODO: .Logger Option on events/server would make this import redundant
stanServer "github.com/nats-io/nats-streaming-server/server"
)
// Server is the entrypoint for the server command.
func Server(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "server",
Usage: fmt.Sprintf("start %s extension without runtime (unsupervised mode)", cfg.Service.Name),
Category: "server",
Before: func(c *cli.Context) error {
return parser.ParseConfig(cfg)
},
Action: func(c *cli.Context) error {
logger := logging.Configure(cfg.Service.Name, cfg.Log)
err := server.RunNatsServer(server.Host(cfg.Nats.Host), server.Port(cfg.Nats.Port), server.StanOpts(func(o *stanServer.Options) {
o.CustomLogger = &logWrapper{logger}
}))
if err != nil {
return err
}
for {
}
},
}
}
// we need to wrap our logger so we can pass it to the nats server
type logWrapper struct {
logger log.Logger
}
// Noticef logs a notice statement
func (l *logWrapper) Noticef(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Info().Msg(msg)
}
// Warnf logs a warning statement
func (l *logWrapper) Warnf(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Warn().Msg(msg)
}
// Fatalf logs a fatal statement
func (l *logWrapper) Fatalf(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Fatal().Msg(msg)
}
// Errorf logs an error statement
func (l *logWrapper) Errorf(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Error().Msg(msg)
}
// Debugf logs a debug statement
func (l *logWrapper) Debugf(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Debug().Msg(msg)
}
// Tracef logs a trace statement
func (l *logWrapper) Tracef(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
l.logger.Trace().Msg(msg)
}
+19
View File
@@ -0,0 +1,19 @@
package command
import (
"github.com/owncloud/ocis/nats/pkg/config"
"github.com/urfave/cli/v2"
)
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "print the version of this binary and the running extension instances",
Category: "info",
Action: func(c *cli.Context) error {
// not implemented
return nil
},
}
}