Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activitylog Service #9327

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ L10N_MODULES := \

# if you add a module here please also add it to the .drone.star file
OCIS_MODULES = \
services/activitylog \
services/antivirus \
services/app-provider \
services/app-registry \
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/activity-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Activitylog Service

Adds a new service `activitylog` which stores events (activities) per resource. This data can be retrieved by clients to show item activities

https://github.com/owncloud/ocis/pull/9327
6 changes: 3 additions & 3 deletions docs/services/general-info/port-ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ We also suggest to use the last port in your extensions' range as a debug/metric
| 9180-9184 | FREE (formerly used by accounts) |
| 9185-9189 | [thumbnails]({{< ref "../thumbnails/_index.md" >}}) |
| 9190-9194 | [settings]({{< ref "../settings/_index.md" >}}) |
| 9195-9197 | FREE |
| 9195-9197 | [activitylog]({{< ref "../activitylog/_index.md" >}}) |
| 9198-9199 | [auth-service]({{< ref "../auth-service/_index.md" >}}) |
| 9200-9204 | [proxy]({{< ref "../proxy/_index.md" >}}) |
| 9205-9209 | [proxy]({{< ref "../proxy/_index.md" >}}) |
Expand All @@ -63,11 +63,11 @@ We also suggest to use the last port in your extensions' range as a debug/metric
| 9245-9249 | FREE |
| 9250-9254 | [ocis server (runtime)](https://github.com/owncloud/ocis/tree/master/ocis/pkg/runtime) |
| 9255-9259 | [postprocessing]({{< ref "../postprocessing/_index.md" >}}) |
| 9260-9264 | [clientlog]({{< ref "../clientlog/_index.md" >}}) |
| 9260-9264 | [clientlog]({{< ref "../clientlog/_index.md" >}}) |
| 9265-9269 | FREE |
| 9270-9274 | [eventhistory]({{< ref "../eventhistory/_index.md" >}}) |
| 9275-9279 | FREE |
| 9280-9284 | [ocm]({{< ref "../ocm/_index.md" >}}) |
| 9280-9284 | [ocm]({{< ref "../ocm/_index.md" >}}) |
| 9285-9289 | FREE |
| 9290-9294 | FREE |
| 9295-9299 | FREE |
Expand Down
2 changes: 2 additions & 0 deletions ocis-pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
activitylog "github.com/owncloud/ocis/v2/services/activitylog/pkg/config"
antivirus "github.com/owncloud/ocis/v2/services/antivirus/pkg/config"
appProvider "github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
appRegistry "github.com/owncloud/ocis/v2/services/app-registry/pkg/config"
Expand Down Expand Up @@ -80,6 +81,7 @@ type Config struct {
AdminUserID string `yaml:"admin_user_id" env:"OCIS_ADMIN_USER_ID" desc:"ID of a user, that should receive admin privileges. Consider that the UUID can be encoded in some LDAP deployment configurations like in .ldif files. These need to be decoded beforehand." introductionVersion:"pre5.0"`
Runtime Runtime `yaml:"runtime"`

Activitylog *activitylog.Config `yaml:"activitylog"`
Antivirus *antivirus.Config `yaml:"antivirus"`
AppProvider *appProvider.Config `yaml:"app_provider"`
AppRegistry *appRegistry.Config `yaml:"app_registry"`
Expand Down
2 changes: 2 additions & 0 deletions ocis-pkg/config/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
activitylog "github.com/owncloud/ocis/v2/services/activitylog/pkg/config/defaults"
antivirus "github.com/owncloud/ocis/v2/services/antivirus/pkg/config/defaults"
appProvider "github.com/owncloud/ocis/v2/services/app-provider/pkg/config/defaults"
appRegistry "github.com/owncloud/ocis/v2/services/app-registry/pkg/config/defaults"
Expand Down Expand Up @@ -52,6 +53,7 @@ func DefaultConfig() *Config {
Host: "localhost",
},

Activitylog: activitylog.DefaultConfig(),
Antivirus: antivirus.DefaultConfig(),
AppProvider: appProvider.DefaultConfig(),
AppRegistry: appRegistry.DefaultConfig(),
Expand Down
6 changes: 6 additions & 0 deletions ocis/pkg/command/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
"github.com/owncloud/ocis/v2/ocis/pkg/command/helper"
"github.com/owncloud/ocis/v2/ocis/pkg/register"
activitylog "github.com/owncloud/ocis/v2/services/activitylog/pkg/command"
antivirus "github.com/owncloud/ocis/v2/services/antivirus/pkg/command"
appprovider "github.com/owncloud/ocis/v2/services/app-provider/pkg/command"
appregistry "github.com/owncloud/ocis/v2/services/app-registry/pkg/command"
Expand Down Expand Up @@ -52,6 +53,11 @@ import (
)

var svccmds = []register.Command{
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.Activitylog.Service.Name, activitylog.GetCommands(cfg.Activitylog), func(c *config.Config) {
cfg.Activitylog.Commons = cfg.Commons
})
},
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.Antivirus.Service.Name, antivirus.GetCommands(cfg.Antivirus), func(c *config.Config) {
// cfg.Antivirus.Commons = cfg.Commons // antivirus needs no commons atm
Expand Down
9 changes: 9 additions & 0 deletions ocis/pkg/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ type Nats struct {
}
}

// Activitylog is the configuration for the activitylog service
type Activitylog struct {
ServiceAccount ServiceAccount `yaml:"service_account"`
}

// ServiceAccount is the configuration for the used service account
type ServiceAccount struct {
ServiceAccountID string `yaml:"service_account_id"`
Expand Down Expand Up @@ -221,6 +226,7 @@ type OcisConfig struct {
Userlog Userlog
AuthService AuthService `yaml:"auth_service"`
Clientlog Clientlog
Activitylog Activitylog
}

func checkConfigPath(configPath string) error {
Expand Down Expand Up @@ -429,6 +435,9 @@ func CreateConfig(insecure, forceOverwrite bool, configPath, adminPassword strin
Settings: SettingsService{
ServiceAccountIDs: []string{serviceAccount.ServiceAccountID},
},
Activitylog: Activitylog{
ServiceAccount: serviceAccount,
},
}

if insecure {
Expand Down
6 changes: 6 additions & 0 deletions ocis/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/owncloud/ocis/v2/ocis-pkg/log"
ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
activitylog "github.com/owncloud/ocis/v2/services/activitylog/pkg/command"
antivirus "github.com/owncloud/ocis/v2/services/antivirus/pkg/command"
appProvider "github.com/owncloud/ocis/v2/services/app-provider/pkg/command"
appRegistry "github.com/owncloud/ocis/v2/services/app-registry/pkg/command"
Expand Down Expand Up @@ -144,6 +145,11 @@ func NewService(options ...Option) (*Service, error) {
// priority group 2 is empty for now

// most services are in priority group 3
reg(3, opts.Config.Activitylog.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
cfg.Activitylog.Context = ctx
cfg.Activitylog.Commons = cfg.Commons
return activitylog.Execute(cfg.Activitylog)
})
reg(3, opts.Config.AppProvider.Service.Name, func(ctx context.Context, cfg *ociscfg.Config) error {
cfg.AppProvider.Context = ctx
cfg.AppProvider.Commons = cfg.Commons
Expand Down
37 changes: 37 additions & 0 deletions services/activitylog/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SHELL := bash
NAME := activitylog

include ../../.make/recursion.mk

############ tooling ############
ifneq (, $(shell command -v go 2> /dev/null)) # suppress "command not found warnings" for non go targets in CI
include ../../.bingo/Variables.mk
endif

############ go tooling ############
include ../../.make/go.mk

############ release ############
include ../../.make/release.mk

############ docs generate ############
include ../../.make/docs.mk

.PHONY: docs-generate
docs-generate: config-docs-generate

############ generate ############
include ../../.make/generate.mk

.PHONY: ci-go-generate
ci-go-generate: # CI runs ci-node-generate automatically before this target

.PHONY: ci-node-generate
ci-node-generate:

############ licenses ############
.PHONY: ci-node-check-licenses
ci-node-check-licenses:

.PHONY: ci-node-save-licenses
ci-node-save-licenses:
15 changes: 15 additions & 0 deletions services/activitylog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Activitylog Service

The `activitylog` service is responsible for storing events (activities) per resource.

## The Log Service Ecosystem

Log services like the `activitylog`, `userlog`, `clientlog` and `sse` are responsible for composing notifications for a specific audience.
- The `userlog` service translates and adjusts messages to be human readable.
- The `clientlog` service composes machine readable messages, so clients can act without the need to query the server.
- The `sse` service is only responsible for sending these messages. It does not care about their form or language.
- The `activitylog` service stores events per resource. These can be retrieved to show item activities

## Activitylog Store

The `activitylog` stores activities for each resource. It works in conjunction with the `eventhistory` service to keep the data it needs to store to a minimum.
14 changes: 14 additions & 0 deletions services/activitylog/cmd/activitylog/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"os"

"github.com/owncloud/ocis/v2/services/activitylog/pkg/command"
"github.com/owncloud/ocis/v2/services/activitylog/pkg/config/defaults"
)

func main() {
if err := command.Execute(defaults.DefaultConfig()); err != nil {
os.Exit(1)
}
}
18 changes: 18 additions & 0 deletions services/activitylog/pkg/command/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package command

import (
"github.com/owncloud/ocis/v2/services/activitylog/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
},
}
}
34 changes: 34 additions & 0 deletions services/activitylog/pkg/command/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package command

import (
"os"

"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
"github.com/owncloud/ocis/v2/services/activitylog/pkg/config"
"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 activitylog command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultApp(&cli.App{
Name: "activitylog",
Usage: "starts activitylog service",
Commands: GetCommands(cfg),
})

return app.Run(os.Args)
}
Loading