 9bdcbe0447
			
		
	
	9bdcbe0447
	
	
	
		
			
			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>
		
			
				
	
	
		
			129 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package goprocess
 | |
| 
 | |
| import (
 | |
| 	"sync"
 | |
| )
 | |
| 
 | |
| // closedCh is an alread-closed channel. used to return
 | |
| // in cases where we already know a channel is closed.
 | |
| var closedCh chan struct{}
 | |
| 
 | |
| func init() {
 | |
| 	closedCh = make(chan struct{})
 | |
| 	close(closedCh)
 | |
| }
 | |
| 
 | |
| // a processLink is an internal bookkeeping datastructure.
 | |
| // it's used to form a relationship between two processes.
 | |
| // It is mostly for keeping memory usage down (letting
 | |
| // children close and be garbage-collected).
 | |
| type processLink struct {
 | |
| 	// guards all fields.
 | |
| 	// DO NOT HOLD while holding process locks.
 | |
| 	// it may be slow, and could deadlock if not careful.
 | |
| 	sync.Mutex
 | |
| 	parent Process
 | |
| 	child  Process
 | |
| }
 | |
| 
 | |
| func newProcessLink(p, c Process) *processLink {
 | |
| 	return &processLink{
 | |
| 		parent: p,
 | |
| 		child:  c,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Closing returns whether the child is closing
 | |
| func (pl *processLink) ChildClosing() <-chan struct{} {
 | |
| 	// grab a hold of it, and unlock, as .Closing may block.
 | |
| 	pl.Lock()
 | |
| 	child := pl.child
 | |
| 	pl.Unlock()
 | |
| 
 | |
| 	if child == nil { // already closed? memory optimization.
 | |
| 		return closedCh
 | |
| 	}
 | |
| 	return child.Closing()
 | |
| }
 | |
| 
 | |
| func (pl *processLink) ChildClosed() <-chan struct{} {
 | |
| 	// grab a hold of it, and unlock, as .Closed may block.
 | |
| 	pl.Lock()
 | |
| 	child := pl.child
 | |
| 	pl.Unlock()
 | |
| 
 | |
| 	if child == nil { // already closed? memory optimization.
 | |
| 		return closedCh
 | |
| 	}
 | |
| 	return child.Closed()
 | |
| }
 | |
| 
 | |
| func (pl *processLink) ChildClose() {
 | |
| 	// grab a hold of it, and unlock, as .Closed may block.
 | |
| 	pl.Lock()
 | |
| 	child := pl.child
 | |
| 	pl.Unlock()
 | |
| 
 | |
| 	if child != nil { // already closed? memory optimization.
 | |
| 		child.Close()
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func (pl *processLink) ClearChild() {
 | |
| 	pl.Lock()
 | |
| 	pl.child = nil
 | |
| 	pl.Unlock()
 | |
| }
 | |
| 
 | |
| func (pl *processLink) ParentClear() {
 | |
| 	pl.Lock()
 | |
| 	pl.parent = nil
 | |
| 	pl.Unlock()
 | |
| }
 | |
| 
 | |
| func (pl *processLink) Child() Process {
 | |
| 	pl.Lock()
 | |
| 	defer pl.Unlock()
 | |
| 	return pl.child
 | |
| }
 | |
| 
 | |
| func (pl *processLink) Parent() Process {
 | |
| 	pl.Lock()
 | |
| 	defer pl.Unlock()
 | |
| 	return pl.parent
 | |
| }
 | |
| 
 | |
| func (pl *processLink) AddToChild() {
 | |
| 	cp := pl.Child()
 | |
| 
 | |
| 	// is it a *process ? if not... panic.
 | |
| 	var c *process
 | |
| 	switch cp := cp.(type) {
 | |
| 	case *process:
 | |
| 		c = cp
 | |
| 	case *bgProcess:
 | |
| 		// Background process never closes so we don't need to do
 | |
| 		// anything.
 | |
| 		return
 | |
| 	default:
 | |
| 		panic("goprocess does not yet support other process impls.")
 | |
| 	}
 | |
| 
 | |
| 	// first, is it Closed?
 | |
| 	c.Lock()
 | |
| 	select {
 | |
| 	case <-c.Closed():
 | |
| 		c.Unlock()
 | |
| 
 | |
| 		// already closed. must not add.
 | |
| 		// we must clear it, though. do so without the lock.
 | |
| 		pl.ClearChild()
 | |
| 		return
 | |
| 
 | |
| 	default:
 | |
| 		// put the process link into q's waiters
 | |
| 		c.waiters = append(c.waiters, pl)
 | |
| 		c.Unlock()
 | |
| 	}
 | |
| }
 |