Skip to content

Commit

Permalink
refactor(search): Extracting search to prepare virtual folder"
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Dec 27, 2022
1 parent ce1f66f commit 642811a
Show file tree
Hide file tree
Showing 12 changed files with 357 additions and 280 deletions.
3 changes: 3 additions & 0 deletions cmd/fibr/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ViBiOh/fibr/pkg/crud"
"github.com/ViBiOh/fibr/pkg/exif"
"github.com/ViBiOh/fibr/pkg/share"
"github.com/ViBiOh/fibr/pkg/storage"
"github.com/ViBiOh/fibr/pkg/thumbnail"
"github.com/ViBiOh/fibr/pkg/webhook"
"github.com/ViBiOh/flags"
Expand All @@ -36,6 +37,7 @@ type configuration struct {
health health.Config
owasp owasp.Config
basic basicMemory.Config
storage storage.Config
crud crud.Config
share share.Config
webhook webhook.Config
Expand Down Expand Up @@ -66,6 +68,7 @@ func newConfig() (configuration, error) {
prometheus: prometheus.Flags(fs, "prometheus", flags.NewOverride("Gzip", false)),
owasp: owasp.Flags(fs, "", flags.NewOverride("FrameOptions", "SAMEORIGIN"), flags.NewOverride("Csp", "default-src 'self'; base-uri 'self'; script-src 'self' 'httputils-nonce' unpkg.com/[email protected]/dist-cjs/ unpkg.com/[email protected]/dist/ unpkg.com/[email protected]/; style-src 'self' 'httputils-nonce' unpkg.com/[email protected]/dist/ unpkg.com/[email protected]/; img-src 'self' data: a.tile.openstreetmap.org b.tile.openstreetmap.org c.tile.openstreetmap.org")),
basic: basicMemory.Flags(fs, "auth", flags.NewOverride("Profiles", "1:admin")),
storage: storage.Flags(fs, ""),
crud: crud.Flags(fs, ""),
share: share.Flags(fs, "share"),
webhook: webhook.Flags(fs, "webhook"),
Expand Down
21 changes: 14 additions & 7 deletions cmd/fibr/fibr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import (
"github.com/ViBiOh/fibr/pkg/exif"
"github.com/ViBiOh/fibr/pkg/fibr"
"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/fibr/pkg/search"
"github.com/ViBiOh/fibr/pkg/share"
"github.com/ViBiOh/fibr/pkg/storage"
"github.com/ViBiOh/fibr/pkg/thumbnail"
"github.com/ViBiOh/fibr/pkg/webhook"
"github.com/ViBiOh/httputils/v4/pkg/alcotest"
Expand Down Expand Up @@ -76,25 +78,28 @@ func main() {

prometheusRegisterer := client.prometheus.Registerer()

storageProvider, err := absto.New(config.absto, client.tracer.GetTracer("storage"))
storageApp, err := absto.New(config.absto, client.tracer.GetTracer("storage"))
logger.Fatal(err)

filteredStorage, err := storage.Get(config.storage, storageApp)
logger.Fatal(err)

eventBus, err := provider.NewEventBus(provider.MaxConcurrency, prometheusRegisterer, client.tracer.GetTracer("bus"))
logger.Fatal(err)

thumbnailApp, err := thumbnail.New(config.thumbnail, storageProvider, client.redis, prometheusRegisterer, client.tracer, client.amqp)
thumbnailApp, err := thumbnail.New(config.thumbnail, storageApp, client.redis, prometheusRegisterer, client.tracer, client.amqp)
logger.Fatal(err)

rendererApp, err := renderer.New(config.renderer, content, fibr.FuncMap, client.tracer.GetTracer("renderer"))
logger.Fatal(err)

exifApp, err := exif.New(config.exif, storageProvider, prometheusRegisterer, client.tracer, client.amqp, client.redis)
exifApp, err := exif.New(config.exif, storageApp, prometheusRegisterer, client.tracer, client.amqp, client.redis)
logger.Fatal(err)

webhookApp, err := webhook.New(config.webhook, storageProvider, prometheusRegisterer, client.amqp, rendererApp, thumbnailApp)
webhookApp, err := webhook.New(config.webhook, storageApp, prometheusRegisterer, client.amqp, rendererApp, thumbnailApp)
logger.Fatal(err)

shareApp, err := share.New(config.share, storageProvider, client.amqp)
shareApp, err := share.New(config.share, storageApp, client.amqp)
logger.Fatal(err)

amqpThumbnailApp, err := amqphandler.New(config.amqpThumbnail, client.amqp, client.tracer.GetTracer("amqp_handler_thumbnail"), thumbnailApp.AMQPHandler)
Expand All @@ -109,7 +114,9 @@ func main() {
amqpWebhookApp, err := amqphandler.New(config.amqpWebhook, client.amqp, client.tracer.GetTracer("amqp_handler_webhook"), webhookApp.AMQPHandler)
logger.Fatal(err)

crudApp, err := crud.New(config.crud, storageProvider, rendererApp, shareApp, webhookApp, thumbnailApp, exifApp, eventBus.Push, client.amqp, client.tracer.GetTracer("crud"))
searchApp := search.New(filteredStorage, thumbnailApp, exifApp, client.tracer.GetTracer("search"))

crudApp, err := crud.New(config.crud, storageApp, filteredStorage, rendererApp, shareApp, webhookApp, thumbnailApp, exifApp, searchApp, eventBus.Push, client.amqp, client.tracer.GetTracer("crud"))
logger.Fatal(err)

var middlewareApp provider.Auth
Expand All @@ -130,7 +137,7 @@ func main() {
go webhookApp.Start(ctx)
go shareApp.Start(ctx)
go crudApp.Start(ctx)
go eventBus.Start(ctx, storageProvider, []provider.Renamer{thumbnailApp.Rename, exifApp.Rename}, shareApp.EventConsumer, thumbnailApp.EventConsumer, exifApp.EventConsumer, webhookApp.EventConsumer)
go eventBus.Start(ctx, storageApp, []provider.Renamer{thumbnailApp.Rename, exifApp.Rename}, shareApp.EventConsumer, thumbnailApp.EventConsumer, exifApp.EventConsumer, webhookApp.EventConsumer)

go promServer.Start("prometheus", client.health.End(), client.prometheus.Handler())
go appServer.Start("http", client.health.End(), httputils.Handler(handler, client.health, recoverer.Middleware, client.prometheus.Middleware, client.tracer.Middleware, owasp.New(config.owasp).Middleware))
Expand Down
2 changes: 1 addition & 1 deletion cmd/fibr/static/styles/main.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmd/fibr/static/styles/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
pointer-events: none;
}

#types {
height: 14.1rem;
}

#size {
width: 7rem;
}
Loading

0 comments on commit 642811a

Please sign in to comment.