Icinga / icingadb

Icinga configuration and state database supporting multiple environments
https://icinga.com
GNU General Public License v2.0
58 stars 20 forks source link

Make structifyStream() channel types more explicit, e.g. input only #797

Closed Al2Klimov closed 1 week ago

Al2Klimov commented 1 month ago

This enforces which side (caller/function) can read and especially close/write to a particular channel at compile time. That leaves less room for bugs (which had to be detected by tests otherwise).

yhabteab commented 1 month ago

I don't understand what this change is supposed to achieve! Previously, nil channels were initialised and immediately closed, and with PR nil channels are assigned to a new closed one. So, which issue is this supposed to fix?

julianbrost commented 1 month ago

I don't understand what this change is supposed to achieve!

Makes it more clear in the function signature, which channels are used for input and which for output.

Previously, nil channels were initialised and immediately closed, and with PR nil channels are assigned to a new closed one. So, which issue is this supposed to fix?

That probably became necessary as otherwise, once you assign a channel to upserted <-chan database.Entity for example, you can no longer close it using that <-chan reference. Therefore, it's assigned to a temporary variable, closed, then assigned to the final variable that no longer allows closing.