MCPcopy Create free account
hub / github.com/buildkite/agent-stack-k8s / flush

Method flush

api/stack_notification_batcher.go:95–113  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

93}
94
95func (nb *notificationBatcher) flush(ctx context.Context) {
96 if len(nb.notifications) == 0 {
97 return
98 }
99
100 count := min(len(nb.notifications), maxNotificationsPerInterval)
101 notifications := make([]stacksapi.StackNotification, count)
102 for i := range count {
103 notifications[i] = <-nb.notifications
104 }
105
106 var wg sync.WaitGroup
107 for batch := range slices.Chunk(notifications, maxNotificationsPerBatch) {
108 wg.Go(func() {
109 nb.sendBatch(ctx, batch)
110 })
111 }
112 wg.Wait()
113}
114
115func (nb *notificationBatcher) sendBatch(ctx context.Context, notifications []stacksapi.StackNotification) {
116 req := stacksapi.CreateStackNotificationsRequest{

Callers 1

startMethod · 0.95

Calls 2

sendBatchMethod · 0.95
WaitMethod · 0.45

Tested by

no test coverage detected