-
Notifications
You must be signed in to change notification settings - Fork 0
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
Query builder #6
Conversation
I.e. don't wait for the complete initial sync first.
contracts.EntitiyFactoryFunc.WithInit() checked for contracts.Initer every time. Now it is only done once in common.NewSyncSubject().
This also requires explicit handling of custom variables as we need to multiplex the original values to handle flat custom variables.
….com/goccy/go-yaml ... not to have GPLv2<->Apache 2.0 (app<->deps) license conflicts.
Make {NotificationHistory,StateHistory,History*}#Id UUID -> SHA1
With this change Icinga DB will insert the environment after each heartbeat takeover if it does not already exist in the database as the environment may have changed, although this is likely to happen very rarely, Instead of checking whether the environment already exists, uses an INSERT statement that does nothing if it does.
The default environment of Icinga is the empty string. In Golang, the zero value of string is also the empty string. But it makes sense to distinguish whether the name is not set or set to the empty string. That is possible with this change.
If the environment changes during runtime, we have to restart HA in order to stop a possibly running config sync and start a new one.
Previously, we selected each entity from the database. Now we only select entities that belong to the current environment.
Icinga/icinga2#9036 introduced a new environment ID for Icinga DB that's written to the icinga:stats stream as field "icingadb_environment". This commit updates the code to make use of this ID instead of the one derived from the Icinga 2 Environment constant.
There's a small risk that when the environment ID changes, Icinga DB could update write into the wrong environment in the database. Therefore, Icinga/icinga2#9036 introduced a new default environment ID based on the CA public key so that there should be no cases where it's required to change the actual environment ID. So if this happens nonetheless, just bail out.
Fix flawed config keys and validation
Rename driver names to `icinga-*sql`
`ColumnMap` provides a cached mapping of structs exported fields to their database column names. By default, all exported struct fields are mapped to their database column names using snake case notation. The `-` (hyphen) directive for the db tag can be used to exclude certain fields. Since `ColumnMap` uses cache, the returned slice MUST NOT be modified directly.
database: Introduce `ColumnMap`
587b1ac
to
ee1d963
Compare
Add go github workflows
ee1d963
to
630cc08
Compare
@oxzi Can you please look at this PR? It's still a draft concept and if you have another better alternative, feel free to suggest it. This PR should basically remove the limitation of how the DB statements are generated. That is, if you want to insert data for some specific columns of a table/type, for instance, you can't do that with the current state, since you have no control at all over which columns you want to use. This now outsources the whole DB statement generation in a new type, which is then controlled by the various |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just went over the PR, mostly compared what vanished from db.go
and appeared in query_builder.go
and wrote down what went through my mind. At first glance, it looks good, I guess.
Thank you for adding tests, which helped me understanding the API's intention and allowed playing with the code.
b5df5ca
to
d97fcc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it a bit and it seems to work as intended. I also switched from msql
to pgsql
for the tests.
Allow to dynamically define type constraint name
d97fcc9
to
05b2800
Compare
Main branch was force pushed because the latest version of the Icinga Go library and the library code in the Icinga DB have diverged. Please create a new PR. |
As GitHub cannot show the diff anymore, maybe due to the branch name reusage within #17, here are the changes backed up from my local machine.
|
Blocked by