Skip to content

Commit

Permalink
Merge pull request #797 from Icinga/structifyStream-iochan
Browse files Browse the repository at this point in the history
Make structifyStream() channel types more explicit, e.g. input only
  • Loading branch information
yhabteab authored Oct 23, 2024
2 parents 3484476 + a3ed042 commit 7214b28
Showing 1 changed file with 13 additions and 6 deletions.
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

0 comments on commit 7214b28

Please sign in to comment.