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>
57 lines
902 B
Go
57 lines
902 B
Go
package timecache
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// FirstSeenCache is a time cache that only marks the expiry of a message when first added.
|
|
type FirstSeenCache struct {
|
|
lk sync.RWMutex
|
|
m map[string]time.Time
|
|
ttl time.Duration
|
|
|
|
done func()
|
|
}
|
|
|
|
var _ TimeCache = (*FirstSeenCache)(nil)
|
|
|
|
func newFirstSeenCache(ttl time.Duration) *FirstSeenCache {
|
|
tc := &FirstSeenCache{
|
|
m: make(map[string]time.Time),
|
|
ttl: ttl,
|
|
}
|
|
|
|
ctx, done := context.WithCancel(context.Background())
|
|
tc.done = done
|
|
go background(ctx, &tc.lk, tc.m)
|
|
|
|
return tc
|
|
}
|
|
|
|
func (tc *FirstSeenCache) Done() {
|
|
tc.done()
|
|
}
|
|
|
|
func (tc *FirstSeenCache) Has(s string) bool {
|
|
tc.lk.RLock()
|
|
defer tc.lk.RUnlock()
|
|
|
|
_, ok := tc.m[s]
|
|
return ok
|
|
}
|
|
|
|
func (tc *FirstSeenCache) Add(s string) bool {
|
|
tc.lk.Lock()
|
|
defer tc.lk.Unlock()
|
|
|
|
_, ok := tc.m[s]
|
|
if ok {
|
|
return false
|
|
}
|
|
|
|
tc.m[s] = time.Now().Add(tc.ttl)
|
|
return true
|
|
}
|