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

add initial loading of facts at startup to the container image located in a specific directory #2062

Open
sschmiedleitner opened this issue Jun 27, 2022 · 8 comments

Comments

@sschmiedleitner
Copy link

when creating a dev env locally, it would be useful to easily setup a factcast server using containers. There is the factcast/factcast image that can be used in unit tests very well, but additionally to that it would be useful, if facts could be loaded from disc during startup automatically as well.

Let's say there is a specific folder in the image /auto-import where a user may add json files (i.e. using volume mapping).

basic json structure proposal:

[
{ "header": <header-json>, "payload": <payload-json>},
...
]

If the folder is empty do not import anything at all (which should be the default in the built image).

@uweschaefer
Copy link
Member

@uweschaefer
Copy link
Member

you'll probably want to control it per test, not per container

@uweschaefer
Copy link
Member

uweschaefer commented Jun 27, 2022

If we wanted to integrate this deeply into the factcast-extension, an alternative would be to use testcontainer's way of initializing the DB:

see JdbcDatabaseContainer::withInitScript

Edit: Turns out this is not an option, as it would execute before liquibase, so that the schema to insert into would not be there.

@uweschaefer
Copy link
Member

But in order to create a fixture, isn't it nicer to publish a bunch of facts via the API ? I feel like this is much more maintainable than having a script with Json (or sql script with INSERTS with json strings) lying around... Maybe i do not understand the usecase enough.

@sschmiedleitner
Copy link
Author

you'll probably want to control it per test, not per container

actually not, since I do not want to execute specific tests but rather startup a full environment (stage) locally. For this, I need a factcast server (of course with a DB behind) and a DB for the read model. Within this setup it would be useful to fill the eventstore with data/facts that the locally started app can consume to create the read-model.

If I need to use the API then I need to write some extra code to achive this, but maybe the easiest path is to create an sql-insert script to fill the "fact" table? Still the escaping is always a cumbersome there...

@uweschaefer
Copy link
Member

That's what i mean: if you publish via API from java, you can get rid of escaping or even writing any json. Isn't that easier to do?

@uweschaefer
Copy link
Member

any feedback on this @sschmiedleitner ?

One collegue did a @BeforeMethod reading a stream from disk (with unescaped headers & payloads) and used fc.publish(Fact.of(JsonNode, JsonNode)) from two nodes read from it. feels as easy as it gets?

@sschmiedleitner
Copy link
Author

no satisfying workarounds for me. but nevermind you can also drop that. It would have just been helpful and nice to have.

But not critical for me for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants