-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use embeddable ocdav go micro service (#3397)
* allow proxy to route to micro service Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * use go micre ocdav service instead of reva frontend Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * add missing gateway default config Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * update reva branch for testing Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * add changelog Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * add missing comands Signed-off-by: Jörn Friedrich Dreyer <[email protected]> * bump reva version Signed-off-by: jkoberg <[email protected]> * tidy Signed-off-by: jkoberg <[email protected]> * bump reva again Signed-off-by: jkoberg <[email protected]> * a blind mans config change Signed-off-by: jkoberg <[email protected]> * add ocdav to must start extensions Signed-off-by: jkoberg <[email protected]> * fail when neither backend nor service is set Signed-off-by: jkoberg <[email protected]> Co-authored-by: jkoberg <[email protected]>
- Loading branch information
Showing
18 changed files
with
310 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Use embeddable ocdav go micro service | ||
|
||
We now use the reva `pgk/micro/ocdav` package that implements a go micro compatible version of the ocdav service. | ||
|
||
https://github.com/owncloud/ocis/pull/3397 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package command | ||
|
||
import ( | ||
"github.com/owncloud/ocis/ocis-pkg/config" | ||
"github.com/owncloud/ocis/ocis/pkg/register" | ||
"github.com/owncloud/ocis/storage/pkg/command" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// OCDavCommand is the entrypoint for the ocdav command. | ||
func OCDavCommand(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "ocdav", | ||
Usage: "start ocdav", | ||
Category: "extensions", | ||
Before: func(ctx *cli.Context) error { | ||
return ParseStorageCommon(ctx, cfg) | ||
}, | ||
Action: func(c *cli.Context) error { | ||
origCmd := command.OCDav(cfg.Storage) | ||
return handleOriginalAction(c, origCmd) | ||
}, | ||
} | ||
} | ||
|
||
func init() { | ||
register.AddCommand(OCDavCommand) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
|
||
"github.com/cs3org/reva/v2/pkg/micro/ocdav" | ||
"github.com/oklog/run" | ||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config" | ||
"github.com/owncloud/ocis/ocis-pkg/sync" | ||
"github.com/owncloud/ocis/storage/pkg/config" | ||
"github.com/owncloud/ocis/storage/pkg/server/debug" | ||
"github.com/owncloud/ocis/storage/pkg/tracing" | ||
"github.com/thejerf/suture/v4" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// OCDav is the entrypoint for the ocdav command. | ||
// TODO move ocdav cmd to a separate service | ||
func OCDav(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "ocdav", | ||
Usage: "start ocdav service", | ||
Before: func(c *cli.Context) error { | ||
if err := loadUserAgent(c, cfg); err != nil { | ||
return err | ||
} | ||
return ParseConfig(c, cfg, "ocdav") | ||
}, | ||
Action: func(c *cli.Context) error { | ||
logger := NewLogger(cfg) | ||
|
||
tracing.Configure(cfg, logger) | ||
|
||
gr := run.Group{} | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
//metrics = metrics.New() | ||
|
||
defer cancel() | ||
|
||
gr.Add(func() error { | ||
s, err := ocdav.Service( | ||
ocdav.Context(ctx), | ||
ocdav.Logger(logger.Logger), | ||
ocdav.Address(cfg.OCDav.Addr), | ||
ocdav.FilesNamespace(cfg.OCDav.FilesNamespace), | ||
ocdav.WebdavNamespace(cfg.OCDav.WebdavNamespace), | ||
ocdav.SharesNamespace(cfg.OCDav.SharesNamespace), | ||
ocdav.Timeout(cfg.OCDav.Timeout), | ||
ocdav.Insecure(cfg.OCDav.Insecure), | ||
ocdav.PublicURL(cfg.OCDav.PublicURL), | ||
ocdav.Prefix(cfg.OCDav.Prefix), | ||
ocdav.GatewaySvc(cfg.OCDav.GatewaySVC), | ||
ocdav.JWTSecret(cfg.OCDav.JWTSecret), | ||
// ocdav.FavoriteManager() // FIXME needs a proper persistence implementation | ||
// ocdav.LockSystem(), // will default to the CS3 lock system | ||
// ocdav.TLSConfig() // tls config for the http server | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return s.Run() | ||
}, func(err error) { | ||
logger.Info().Err(err).Str("server", c.Command.Name).Msg("Shutting down server") | ||
cancel() | ||
}) | ||
|
||
{ | ||
server, err := debug.Server( | ||
debug.Name(c.Command.Name+"-debug"), | ||
debug.Addr(cfg.OCDav.DebugAddr), | ||
debug.Logger(logger), | ||
debug.Context(ctx), | ||
debug.Config(cfg), | ||
) | ||
|
||
if err != nil { | ||
logger.Info(). | ||
Err(err). | ||
Str("server", "debug"). | ||
Msg("Failed to initialize server") | ||
|
||
return err | ||
} | ||
|
||
gr.Add(server.ListenAndServe, func(_ error) { | ||
cancel() | ||
}) | ||
} | ||
|
||
if !cfg.Reva.Frontend.Supervised { | ||
sync.Trap(&gr, cancel) | ||
} | ||
|
||
return gr.Run() | ||
}, | ||
} | ||
} | ||
|
||
// OCDavSutureService allows for the ocdav command to be embedded and supervised by a suture supervisor tree. | ||
type OCDavSutureService struct { | ||
cfg *config.Config | ||
} | ||
|
||
// NewOCDav creates a new ocdav.OCDavSutureService | ||
func NewOCDav(cfg *ociscfg.Config) suture.Service { | ||
cfg.Storage.Commons = cfg.Commons | ||
return OCDavSutureService{ | ||
cfg: cfg.Storage, | ||
} | ||
} | ||
|
||
func (s OCDavSutureService) Serve(ctx context.Context) error { | ||
s.cfg.Reva.Frontend.Context = ctx | ||
f := &flag.FlagSet{} | ||
cmdFlags := OCDav(s.cfg).Flags | ||
for k := range cmdFlags { | ||
if err := cmdFlags[k].Apply(f); err != nil { | ||
return err | ||
} | ||
} | ||
cliCtx := cli.NewContext(nil, f, nil) | ||
if OCDav(s.cfg).Before != nil { | ||
if err := OCDav(s.cfg).Before(cliCtx); err != nil { | ||
return err | ||
} | ||
} | ||
if err := OCDav(s.cfg).Action(cliCtx); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.