Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package pubsub
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
)
|
|
|
|
// Subscription handles the details of a particular Topic subscription.
|
|
// There may be many subscriptions for a given Topic.
|
|
type Subscription struct {
|
|
topic string
|
|
ch chan *Message
|
|
cancelCh chan<- *Subscription
|
|
ctx context.Context
|
|
err error
|
|
once sync.Once
|
|
}
|
|
|
|
// Topic returns the topic string associated with the Subscription
|
|
func (sub *Subscription) Topic() string {
|
|
return sub.topic
|
|
}
|
|
|
|
// Next returns the next message in our subscription
|
|
func (sub *Subscription) Next(ctx context.Context) (*Message, error) {
|
|
select {
|
|
case msg, ok := <-sub.ch:
|
|
if !ok {
|
|
return msg, sub.err
|
|
}
|
|
|
|
return msg, nil
|
|
case <-ctx.Done():
|
|
return nil, ctx.Err()
|
|
}
|
|
}
|
|
|
|
// Cancel closes the subscription. If this is the last active subscription then pubsub will send an unsubscribe
|
|
// announcement to the network.
|
|
func (sub *Subscription) Cancel() {
|
|
select {
|
|
case sub.cancelCh <- sub:
|
|
case <-sub.ctx.Done():
|
|
}
|
|
}
|
|
|
|
func (sub *Subscription) close() {
|
|
sub.once.Do(func() {
|
|
close(sub.ch)
|
|
})
|
|
}
|