Skip to content

Commit

Permalink
Make structifyStream() channel types more explicit, e.g. input only
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Sep 4, 2024
1 parent 277a61d commit 3ee2669
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/icingadb/runtime_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,19 @@ 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 3ee2669

Please sign in to comment.