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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions pkg/icingadb/runtime_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,24 @@ func (r *RuntimeUpdates) xRead(ctx context.Context, updateMessagesByKey map[stri
// those messages into Icinga DB entities (contracts.Entity) using the provided structifier.
// Converted entities are inserted into the upsertEntities or deleteIds channel depending on the "runtime_type" message field.
func structifyStream(
ctx context.Context, updateMessages <-chan redis.XMessage, upsertEntities, upserted chan database.Entity,
deleteIds, deleted chan interface{}, structifier structify.MapStructifier,
ctx context.Context,
updateMessages <-chan redis.XMessage,
upsertEntities chan<- database.Entity,
upserted <-chan database.Entity,
deleteIds chan<- any,
deleted <-chan any,
structifier structify.MapStructifier,
) func() error {
if upserted == nil {
upserted = make(chan database.Entity)
close(upserted)
ch := make(chan database.Entity)
close(ch)
upserted = ch
}

if deleted == nil {
deleted = make(chan interface{})
close(deleted)
ch := make(chan any)
close(ch)
deleted = ch
}

return func() error {
Expand Down
Loading