justtrackio / gosoline

Gosoline is our framework which fuels all of our Golang applications
MIT License
93 stars 50 forks source link

mdlsub: http source based fixture writer for subscribers #1154

Closed j4k4 closed 3 weeks ago

j4k4 commented 1 month ago

closes #1152

This PR contains two major changes related to processing fixtures:

fixture groups

On adding fixtures sets to an application, one has to define the group into which the data belongs as the first argument. \

app := application.Default(
    application.WithFixtureSetFactory("default", fixtureSetsFactory),
)

The default group is loaded on default and can be defined in the config:

fixtures:
  enabled: true
  groups: ["default"]

subscriber fixture loading

The mdlsub contains a FixtureSetFactory now which enables fixture loading for subscribers via http endpoints.\ On subscriber start the app will request the fixtures via http and persists the data into the configured outputs.

application.RunMdlSubscriber(
    subscribers.Transformers,
    application.WithFixtureSetFactory("subscriber", mdlsub.FixtureSetFactory(subscribers.Transformers)),
)

The source is set via config:

fixtures:
  enabled: true
  groups: ["subscriber"]
  providers:
    subscriber:
      host: http://fixtures.io
      path: /v0/fixtures/subscriber
      dataset_name: management