 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>
		
			
				
	
	
		
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package log
 | |
| 
 | |
| import (
 | |
| 	"encoding/json"
 | |
| 	"errors"
 | |
| 	"reflect"
 | |
| )
 | |
| 
 | |
| // Metadata is a convenience type for generic maps
 | |
| type Metadata map[string]interface{}
 | |
| 
 | |
| // DeepMerge merges the second Metadata parameter into the first.
 | |
| // Nested Metadata are merged recursively. Primitives are over-written.
 | |
| func DeepMerge(b, a Metadata) Metadata {
 | |
| 	out := Metadata{}
 | |
| 	for k, v := range b {
 | |
| 		out[k] = v
 | |
| 	}
 | |
| 	for k, v := range a {
 | |
| 
 | |
| 		maybe, err := Metadatify(v)
 | |
| 		if err != nil {
 | |
| 			// if the new value is not meta. just overwrite the dest vaue
 | |
| 			if out[k] != nil {
 | |
| 				log.Debugf("Overwriting key: %s, old: %s, new: %s", k, out[k], v)
 | |
| 			}
 | |
| 			out[k] = v
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		// it is meta. What about dest?
 | |
| 		outv, exists := out[k]
 | |
| 		if !exists {
 | |
| 			// the new value is meta, but there's no dest value. just write it
 | |
| 			out[k] = v
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		outMetadataValue, err := Metadatify(outv)
 | |
| 		if err != nil {
 | |
| 			// the new value is meta and there's a dest value, but the dest
 | |
| 			// value isn't meta. just overwrite
 | |
| 			out[k] = v
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		// both are meta. merge them.
 | |
| 		out[k] = DeepMerge(outMetadataValue, maybe)
 | |
| 	}
 | |
| 	return out
 | |
| }
 | |
| 
 | |
| // Loggable implements the Loggable interface.
 | |
| func (m Metadata) Loggable() map[string]interface{} {
 | |
| 	// NB: method defined on value to avoid de-referencing nil Metadata
 | |
| 	return m
 | |
| }
 | |
| 
 | |
| // JsonString returns the marshaled JSON string for the metadata.
 | |
| func (m Metadata) JsonString() (string, error) {
 | |
| 	// NB: method defined on value
 | |
| 	b, err := json.Marshal(m)
 | |
| 	return string(b), err
 | |
| }
 | |
| 
 | |
| // Metadatify converts maps into Metadata.
 | |
| func Metadatify(i interface{}) (Metadata, error) {
 | |
| 	value := reflect.ValueOf(i)
 | |
| 	if value.Kind() == reflect.Map {
 | |
| 		m := map[string]interface{}{}
 | |
| 		for _, k := range value.MapKeys() {
 | |
| 			m[k.String()] = value.MapIndex(k).Interface()
 | |
| 		}
 | |
| 		return Metadata(m), nil
 | |
| 	}
 | |
| 	return nil, errors.New("is not a map")
 | |
| }
 |