Compare commits
	
		
			16 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8c16e4d982 | |||
| 039a53a395 | |||
| 2cf571579b | |||
| 9a537bb8c2 | |||
| 78ad103151 | |||
| c764a946ff | |||
| ef59b1241f | |||
| a70ab33559 | |||
| a58bb4b14b | |||
| dc62bbe55f | |||
| b832d77d3e | |||
| 38467cb4e7 | |||
| 68b06158b3 | |||
| 5f51173276 | |||
| 1586314e3e | |||
| 254fe1556a | 
							
								
								
									
										6
									
								
								.idea/copilot.data.migration.agent.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/copilot.data.migration.agent.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="AgentMigrationStateService"> | ||||||
|  |     <option name="migrationStatus" value="COMPLETED" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										6
									
								
								.idea/copilot.data.migration.ask.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/copilot.data.migration.ask.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="AskMigrationStateService"> | ||||||
|  |     <option name="migrationStatus" value="COMPLETED" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										6
									
								
								.idea/copilot.data.migration.ask2agent.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/copilot.data.migration.ask2agent.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="Ask2AgentMigrationStateService"> | ||||||
|  |     <option name="migrationStatus" value="COMPLETED" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
							
								
								
									
										6
									
								
								.idea/copilot.data.migration.edit.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.idea/copilot.data.migration.edit.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project version="4"> | ||||||
|  |   <component name="EditMigrationStateService"> | ||||||
|  |     <option name="migrationStatus" value="COMPLETED" /> | ||||||
|  |   </component> | ||||||
|  | </project> | ||||||
| @@ -117,6 +117,20 @@ func (e {{.EnumTypeName}}) DescriptionMeta() enums.EnumDescriptionMetaValue { | |||||||
| } | } | ||||||
| {{end}} | {{end}} | ||||||
|  |  | ||||||
|  | {{if $hasData}} | ||||||
|  | func (e {{.EnumTypeName}}) DataMeta() enums.EnumDataMetaValue { | ||||||
|  |     return enums.EnumDataMetaValue{ | ||||||
|  |         VarName: e.VarName(), | ||||||
|  |         Value: e, | ||||||
|  |         Description: e.Description(), | ||||||
|  |         Data: map[string]any{ | ||||||
|  |             {{ range $datakey, $datatype := $enumdef | generalDataKeys  }} "{{ $datakey }}": e.Data().{{ $datakey | godatakey }}, | ||||||
|  |             {{ end }} | ||||||
|  |         }, | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | {{end}} | ||||||
|  |  | ||||||
| func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) { | func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) { | ||||||
| 	for _, ev := range __{{.EnumTypeName}}Values { | 	for _, ev := range __{{.EnumTypeName}}Values { | ||||||
| 		if string(ev) == vv { | 		if string(ev) == vv { | ||||||
| @@ -136,6 +150,12 @@ func {{.EnumTypeName}}ValuesMeta() []enums.EnumMetaValue { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func {{.EnumTypeName}}ValuesDataMeta() []enums.EnumMetaValue { | ||||||
|  | 	return []enums.EnumDataMetaValue{ {{range .Values}} | ||||||
|  |             {{.VarName}}.DataMeta(), {{end}} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| {{if $hasDescr}} | {{if $hasDescr}} | ||||||
| func {{.EnumTypeName}}ValuesDescriptionMeta() []enums.EnumDescriptionMetaValue { | func {{.EnumTypeName}}ValuesDescriptionMeta() []enums.EnumDescriptionMetaValue { | ||||||
| 	return []enums.EnumDescriptionMetaValue{ {{range .Values}} | 	return []enums.EnumDescriptionMetaValue{ {{range .Values}} | ||||||
|   | |||||||
| @@ -6,13 +6,15 @@ import ( | |||||||
| 	"crypto/sha512" | 	"crypto/sha512" | ||||||
| 	"encoding/base64" | 	"encoding/base64" | ||||||
| 	"encoding/hex" | 	"encoding/hex" | ||||||
|  | 	"encoding/json" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"strconv" | ||||||
|  | 	"strings" | ||||||
|  |  | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/totpext" | 	"git.blackforestbytes.com/BlackForestBytes/goext/totpext" | ||||||
| 	"golang.org/x/crypto/bcrypt" | 	"golang.org/x/crypto/bcrypt" | ||||||
| 	"strconv" |  | ||||||
| 	"strings" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const LatestPassHashVersion = 5 | const LatestPassHashVersion = 5 | ||||||
| @@ -317,6 +319,13 @@ func (ph PassHash) String() string { | |||||||
| 	return string(ph) | 	return string(ph) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (ph PassHash) MarshalJSON() ([]byte, error) { | ||||||
|  | 	if ph == "" { | ||||||
|  | 		return json.Marshal("") | ||||||
|  | 	} | ||||||
|  | 	return json.Marshal("*****") | ||||||
|  | } | ||||||
|  |  | ||||||
| func HashPassword(plainpass string, totpSecret []byte) (PassHash, error) { | func HashPassword(plainpass string, totpSecret []byte) (PassHash, error) { | ||||||
| 	return HashPasswordV5(plainpass, totpSecret) | 	return HashPasswordV5(plainpass, totpSecret) | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										230
									
								
								dataext/broadcaster.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										230
									
								
								dataext/broadcaster.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,230 @@ | |||||||
|  | package dataext | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"iter" | ||||||
|  | 	"sync" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/syncext" | ||||||
|  | 	"github.com/rs/xid" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | // Broadcaster is a simple Broadcaster channel | ||||||
|  | // This is a simpler interface over Broadcaster - which does not have distinct namespaces | ||||||
|  | type Broadcaster[TData any] struct { | ||||||
|  | 	masterLock *sync.Mutex | ||||||
|  |  | ||||||
|  | 	subscriptions []*broadcastSubscription[TData] | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type BroadcastSubscription interface { | ||||||
|  | 	Unsubscribe() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type broadcastSubscription[TData any] struct { | ||||||
|  | 	ID string | ||||||
|  |  | ||||||
|  | 	parent *Broadcaster[TData] | ||||||
|  |  | ||||||
|  | 	subLock *sync.Mutex | ||||||
|  |  | ||||||
|  | 	Func func(TData) | ||||||
|  | 	Chan chan TData | ||||||
|  |  | ||||||
|  | 	UnsubChan chan bool | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (p *broadcastSubscription[TData]) Unsubscribe() { | ||||||
|  | 	p.parent.unsubscribe(p) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func NewBroadcaster[TData any](capacity int) *Broadcaster[TData] { | ||||||
|  | 	return &Broadcaster[TData]{ | ||||||
|  | 		masterLock:    &sync.Mutex{}, | ||||||
|  | 		subscriptions: make([]*broadcastSubscription[TData], 0, capacity), | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (bb *Broadcaster[TData]) SubscriberCount() int { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	defer bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	return len(bb.subscriptions) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Publish sends `data` to all subscriber | ||||||
|  | // But unbuffered - if one is currently not listening, we skip (the actualReceiver < subscriber) | ||||||
|  | func (bb *Broadcaster[TData]) Publish(data TData) (subscriber int, actualReceiver int) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	subs := langext.ArrCopy(bb.subscriptions) | ||||||
|  | 	bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	subscriber = len(subs) | ||||||
|  | 	actualReceiver = 0 | ||||||
|  |  | ||||||
|  | 	for _, sub := range subs { | ||||||
|  | 		func() { | ||||||
|  | 			sub.subLock.Lock() | ||||||
|  | 			defer sub.subLock.Unlock() | ||||||
|  |  | ||||||
|  | 			if sub.Func != nil { | ||||||
|  | 				go func() { sub.Func(data) }() | ||||||
|  | 				actualReceiver++ | ||||||
|  | 			} else if sub.Chan != nil { | ||||||
|  | 				msgSent := syncext.WriteNonBlocking(sub.Chan, data) | ||||||
|  | 				if msgSent { | ||||||
|  | 					actualReceiver++ | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return subscriber, actualReceiver | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // PublishWithContext sends `data` to all subscriber | ||||||
|  | // buffered - if one is currently not listening, we wait (but error out when the context runs out) | ||||||
|  | func (bb *Broadcaster[TData]) PublishWithContext(ctx context.Context, data TData) (subscriber int, actualReceiver int, err error) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	subs := langext.ArrCopy(bb.subscriptions) | ||||||
|  | 	bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	subscriber = len(subs) | ||||||
|  | 	actualReceiver = 0 | ||||||
|  |  | ||||||
|  | 	for _, sub := range subs { | ||||||
|  | 		err := func() error { | ||||||
|  | 			sub.subLock.Lock() | ||||||
|  | 			defer sub.subLock.Unlock() | ||||||
|  |  | ||||||
|  | 			if err := ctx.Err(); err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if sub.Func != nil { | ||||||
|  | 				go func() { sub.Func(data) }() | ||||||
|  | 				actualReceiver++ | ||||||
|  | 			} else if sub.Chan != nil { | ||||||
|  | 				err := syncext.WriteChannelWithContext(ctx, sub.Chan, data) | ||||||
|  | 				if err != nil { | ||||||
|  | 					return err | ||||||
|  | 				} | ||||||
|  | 				actualReceiver++ | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			return nil | ||||||
|  | 		}() | ||||||
|  | 		if err != nil { | ||||||
|  | 			return subscriber, actualReceiver, err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return subscriber, actualReceiver, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // PublishWithTimeout sends `data` to all subscriber | ||||||
|  | // buffered - if one is currently not listening, we wait (but wait at most `timeout` - if the timeout is exceeded then actualReceiver < subscriber) | ||||||
|  | func (bb *Broadcaster[TData]) PublishWithTimeout(data TData, timeout time.Duration) (subscriber int, actualReceiver int) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	subs := langext.ArrCopy(bb.subscriptions) | ||||||
|  | 	bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	subscriber = len(subs) | ||||||
|  | 	actualReceiver = 0 | ||||||
|  |  | ||||||
|  | 	for _, sub := range subs { | ||||||
|  | 		func() { | ||||||
|  | 			sub.subLock.Lock() | ||||||
|  | 			defer sub.subLock.Unlock() | ||||||
|  |  | ||||||
|  | 			if sub.Func != nil { | ||||||
|  | 				go func() { sub.Func(data) }() | ||||||
|  | 				actualReceiver++ | ||||||
|  | 			} else if sub.Chan != nil { | ||||||
|  | 				ok := syncext.WriteChannelWithTimeout(sub.Chan, data, timeout) | ||||||
|  | 				if ok { | ||||||
|  | 					actualReceiver++ | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return subscriber, actualReceiver | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (bb *Broadcaster[TData]) SubscribeByCallback(fn func(TData)) BroadcastSubscription { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	defer bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	sub := &broadcastSubscription[TData]{ID: xid.New().String(), parent: bb, subLock: &sync.Mutex{}, Func: fn, UnsubChan: nil} | ||||||
|  |  | ||||||
|  | 	bb.subscriptions = append(bb.subscriptions, sub) | ||||||
|  |  | ||||||
|  | 	return sub | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (bb *Broadcaster[TData]) SubscribeByChan(chanBufferSize int) (chan TData, BroadcastSubscription) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	defer bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	msgCh := make(chan TData, chanBufferSize) | ||||||
|  |  | ||||||
|  | 	sub := &broadcastSubscription[TData]{ID: xid.New().String(), parent: bb, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: nil} | ||||||
|  |  | ||||||
|  | 	bb.subscriptions = append(bb.subscriptions, sub) | ||||||
|  |  | ||||||
|  | 	return msgCh, sub | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (bb *Broadcaster[TData]) SubscribeByIter(chanBufferSize int) (iter.Seq[TData], BroadcastSubscription) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	defer bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	msgCh := make(chan TData, chanBufferSize) | ||||||
|  | 	unsubChan := make(chan bool, 8) | ||||||
|  |  | ||||||
|  | 	sub := &broadcastSubscription[TData]{ID: xid.New().String(), parent: bb, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: unsubChan} | ||||||
|  |  | ||||||
|  | 	bb.subscriptions = append(bb.subscriptions, sub) | ||||||
|  |  | ||||||
|  | 	iterFun := func(yield func(TData) bool) { | ||||||
|  | 		for { | ||||||
|  | 			select { | ||||||
|  | 			case msg := <-msgCh: | ||||||
|  | 				if !yield(msg) { | ||||||
|  | 					sub.Unsubscribe() | ||||||
|  | 					return | ||||||
|  | 				} | ||||||
|  | 			case <-sub.UnsubChan: | ||||||
|  | 				sub.Unsubscribe() | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return iterFun, sub | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (bb *Broadcaster[TData]) unsubscribe(p *broadcastSubscription[TData]) { | ||||||
|  | 	bb.masterLock.Lock() | ||||||
|  | 	defer bb.masterLock.Unlock() | ||||||
|  |  | ||||||
|  | 	p.subLock.Lock() | ||||||
|  | 	defer p.subLock.Unlock() | ||||||
|  |  | ||||||
|  | 	if p.Chan != nil { | ||||||
|  | 		close(p.Chan) | ||||||
|  | 		p.Chan = nil | ||||||
|  | 	} | ||||||
|  | 	if p.UnsubChan != nil { | ||||||
|  | 		syncext.WriteNonBlocking(p.UnsubChan, true) | ||||||
|  | 		close(p.UnsubChan) | ||||||
|  | 		p.UnsubChan = nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	bb.subscriptions = langext.ArrFilter(bb.subscriptions, func(v *broadcastSubscription[TData]) bool { | ||||||
|  | 		return v.ID != p.ID | ||||||
|  | 	}) | ||||||
|  | } | ||||||
							
								
								
									
										332
									
								
								dataext/broadcaster_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										332
									
								
								dataext/broadcaster_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,332 @@ | |||||||
|  | package dataext | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"sync" | ||||||
|  | 	"testing" | ||||||
|  | 	"time" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func TestNewBroadcast(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  | 	if bb == nil { | ||||||
|  | 		t.Fatal("NewBroadcaster returned nil") | ||||||
|  | 	} | ||||||
|  | 	if bb.masterLock == nil { | ||||||
|  | 		t.Fatal("masterLock is nil") | ||||||
|  | 	} | ||||||
|  | 	if bb.subscriptions == nil { | ||||||
|  | 		t.Fatal("subscriptions is nil") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_SubscribeByCallback(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	var received string | ||||||
|  | 	var wg sync.WaitGroup | ||||||
|  | 	wg.Add(1) | ||||||
|  |  | ||||||
|  | 	callback := func(msg string) { | ||||||
|  | 		received = msg | ||||||
|  | 		wg.Done() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	sub := bb.SubscribeByCallback(callback) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Publish a message | ||||||
|  | 	subs, receivers := bb.Publish("hello") | ||||||
|  |  | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Wait for the callback to be executed | ||||||
|  | 	wg.Wait() | ||||||
|  |  | ||||||
|  | 	if received != "hello" { | ||||||
|  | 		t.Fatalf("Expected to receive 'hello', got '%s'", received) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_SubscribeByChan(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	ch, sub := bb.SubscribeByChan(1) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Publish a message | ||||||
|  | 	subs, receivers := bb.Publish("hello") | ||||||
|  |  | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Read from the channel with a timeout to avoid blocking | ||||||
|  | 	select { | ||||||
|  | 	case msg := <-ch: | ||||||
|  | 		if msg != "hello" { | ||||||
|  | 			t.Fatalf("Expected to receive 'hello', got '%s'", msg) | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_SubscribeByIter(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	iterSeq, sub := bb.SubscribeByIter(1) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Channel to communicate when message is received | ||||||
|  | 	done := make(chan bool) | ||||||
|  | 	received := false | ||||||
|  |  | ||||||
|  | 	// Start a goroutine to use the iterator | ||||||
|  | 	go func() { | ||||||
|  | 		for msg := range iterSeq { | ||||||
|  | 			if msg == "hello" { | ||||||
|  | 				received = true | ||||||
|  | 				done <- true | ||||||
|  | 				return // Stop iteration | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	// Give time for the iterator to start | ||||||
|  | 	time.Sleep(100 * time.Millisecond) | ||||||
|  |  | ||||||
|  | 	// Publish a message | ||||||
|  | 	bb.Publish("hello") | ||||||
|  |  | ||||||
|  | 	// Wait for the message to be received or timeout | ||||||
|  | 	select { | ||||||
|  | 	case <-done: | ||||||
|  | 		if !received { | ||||||
|  | 			t.Fatal("Message was received but not 'hello'") | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	subCount := bb.SubscriberCount() | ||||||
|  | 	if subCount != 0 { | ||||||
|  | 		t.Fatalf("Expected 0 receivers, got %d", subCount) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_Publish(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	// Test publishing with no subscribers | ||||||
|  | 	subs, receivers := bb.Publish("hello") | ||||||
|  | 	if subs != 0 { | ||||||
|  | 		t.Fatalf("Expected 0 subscribers, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 0 { | ||||||
|  | 		t.Fatalf("Expected 0 receivers, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Add a subscriber | ||||||
|  | 	ch, sub := bb.SubscribeByChan(1) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Publish a message | ||||||
|  | 	subs, receivers = bb.Publish("hello") | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Verify the message was received | ||||||
|  | 	select { | ||||||
|  | 	case msg := <-ch: | ||||||
|  | 		if msg != "hello" { | ||||||
|  | 			t.Fatalf("Expected to receive 'hello', got '%s'", msg) | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Test non-blocking behavior with a full channel | ||||||
|  | 	// First fill the channel | ||||||
|  | 	bb.Publish("fill") | ||||||
|  |  | ||||||
|  | 	// Now publish again - this should not block but may skip the receiver | ||||||
|  | 	subs, receivers = bb.Publish("overflow") | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	_ = receivers // may be 0 if channel is full | ||||||
|  |  | ||||||
|  | 	// Drain the channel | ||||||
|  | 	<-ch | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_PublishWithTimeout(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	// Add a subscriber with a channel | ||||||
|  | 	ch, sub := bb.SubscribeByChan(1) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Publish with a timeout | ||||||
|  | 	subs, receivers := bb.PublishWithTimeout("hello", 100*time.Millisecond) | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Verify the message was received | ||||||
|  | 	select { | ||||||
|  | 	case msg := <-ch: | ||||||
|  | 		if msg != "hello" { | ||||||
|  | 			t.Fatalf("Expected to receive 'hello', got '%s'", msg) | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Fill the channel | ||||||
|  | 	bb.Publish("fill") | ||||||
|  |  | ||||||
|  | 	// Test timeout behavior with a full channel | ||||||
|  | 	start := time.Now() | ||||||
|  | 	subs, receivers = bb.PublishWithTimeout("timeout-test", 50*time.Millisecond) | ||||||
|  | 	elapsed := time.Since(start) | ||||||
|  |  | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// The receiver count should be 0 if the timeout occurred | ||||||
|  | 	if elapsed < 50*time.Millisecond { | ||||||
|  | 		t.Fatalf("Expected to wait at least 50ms, only waited %v", elapsed) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Drain the channel | ||||||
|  | 	<-ch | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_PublishWithContext(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	// Add a subscriber with a channel | ||||||
|  | 	ch, sub := bb.SubscribeByChan(1) | ||||||
|  | 	defer sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Create a context | ||||||
|  | 	ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) | ||||||
|  | 	defer cancel() | ||||||
|  |  | ||||||
|  | 	// Publish with context | ||||||
|  | 	subs, receivers, err := bb.PublishWithContext(ctx, "hello") | ||||||
|  | 	if err != nil { | ||||||
|  | 		t.Fatalf("Unexpected error: %v", err) | ||||||
|  | 	} | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Verify the message was received | ||||||
|  | 	select { | ||||||
|  | 	case msg := <-ch: | ||||||
|  | 		if msg != "hello" { | ||||||
|  | 			t.Fatalf("Expected to receive 'hello', got '%s'", msg) | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Fill the channel | ||||||
|  | 	bb.Publish("fill") | ||||||
|  |  | ||||||
|  | 	// Test context cancellation with a full channel | ||||||
|  | 	ctx, cancel = context.WithCancel(context.Background()) | ||||||
|  |  | ||||||
|  | 	// Cancel the context after a short delay | ||||||
|  | 	go func() { | ||||||
|  | 		time.Sleep(50 * time.Millisecond) | ||||||
|  | 		cancel() | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	start := time.Now() | ||||||
|  | 	subs, receivers, err = bb.PublishWithContext(ctx, "context-test") | ||||||
|  | 	elapsed := time.Since(start) | ||||||
|  |  | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Should get a context canceled error | ||||||
|  | 	if err == nil { | ||||||
|  | 		t.Fatal("Expected context canceled error, got nil") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if elapsed < 50*time.Millisecond { | ||||||
|  | 		t.Fatalf("Expected to wait at least 50ms, only waited %v", elapsed) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Drain the channel | ||||||
|  | 	<-ch | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestBroadcast_Unsubscribe(t *testing.T) { | ||||||
|  | 	bb := NewBroadcaster[string](10) | ||||||
|  |  | ||||||
|  | 	// Add a subscriber | ||||||
|  | 	ch, sub := bb.SubscribeByChan(1) | ||||||
|  |  | ||||||
|  | 	// Publish a message | ||||||
|  | 	subs, receivers := bb.Publish("hello") | ||||||
|  | 	if subs != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 subscriber, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 1 { | ||||||
|  | 		t.Fatalf("Expected 1 receiver, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Verify the message was received | ||||||
|  | 	select { | ||||||
|  | 	case msg := <-ch: | ||||||
|  | 		if msg != "hello" { | ||||||
|  | 			t.Fatalf("Expected to receive 'hello', got '%s'", msg) | ||||||
|  | 		} | ||||||
|  | 	case <-time.After(time.Second): | ||||||
|  | 		t.Fatal("Timed out waiting for message") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Unsubscribe | ||||||
|  | 	sub.Unsubscribe() | ||||||
|  |  | ||||||
|  | 	// Publish again | ||||||
|  | 	subs, receivers = bb.Publish("after-unsub") | ||||||
|  | 	if subs != 0 { | ||||||
|  | 		t.Fatalf("Expected 0 subscribers after unsubscribe, got %d", subs) | ||||||
|  | 	} | ||||||
|  | 	if receivers != 0 { | ||||||
|  | 		t.Fatalf("Expected 0 receivers after unsubscribe, got %d", receivers) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Check that the subscriber count is 0 | ||||||
|  | 	if bb.SubscriberCount() != 0 { | ||||||
|  | 		t.Fatalf("Expected SubscriberCount() == 0, got %d", bb.SubscriberCount()) | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -2,12 +2,19 @@ package dataext | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" |  | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/syncext" |  | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/syncext" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // DelayedCombiningInvoker is a utility to combine multiple consecutive requests into a single execution | ||||||
|  | // | ||||||
|  | // Requests are made with Request(), and consecutive requests are combined during the `delay` period. | ||||||
|  | // | ||||||
|  | // Can be used, e.g., for search-controls, where we want to init the search when teh user stops typing | ||||||
|  | // Or generally to queue an execution once a burst of requests is over. | ||||||
| type DelayedCombiningInvoker struct { | type DelayedCombiningInvoker struct { | ||||||
| 	syncLock           sync.Mutex | 	syncLock           sync.Mutex | ||||||
| 	triggerChan        chan bool | 	triggerChan        chan bool | ||||||
| @@ -17,8 +24,13 @@ type DelayedCombiningInvoker struct { | |||||||
| 	delay              time.Duration | 	delay              time.Duration | ||||||
| 	maxDelay           time.Duration | 	maxDelay           time.Duration | ||||||
| 	executorRunning    *syncext.AtomicBool | 	executorRunning    *syncext.AtomicBool | ||||||
|  | 	pendingRequests    *syncext.Atomic[int] | ||||||
| 	lastRequestTime    time.Time | 	lastRequestTime    time.Time | ||||||
| 	initialRequestTime time.Time | 	initialRequestTime time.Time | ||||||
|  |  | ||||||
|  | 	onExecutionStart []func(immediately bool)          // listener ( actual execution of action starts ) | ||||||
|  | 	onExecutionDone  []func()                          // listener ( actual execution of action finished ) | ||||||
|  | 	onRequest        []func(pending int, initial bool) // listener ( a request came in, waiting for execution ) | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewDelayedCombiningInvoker(action func(), delay time.Duration, maxDelay time.Duration) *DelayedCombiningInvoker { | func NewDelayedCombiningInvoker(action func(), delay time.Duration, maxDelay time.Duration) *DelayedCombiningInvoker { | ||||||
| @@ -27,11 +39,15 @@ func NewDelayedCombiningInvoker(action func(), delay time.Duration, maxDelay tim | |||||||
| 		delay:              delay, | 		delay:              delay, | ||||||
| 		maxDelay:           maxDelay, | 		maxDelay:           maxDelay, | ||||||
| 		executorRunning:    syncext.NewAtomicBool(false), | 		executorRunning:    syncext.NewAtomicBool(false), | ||||||
|  | 		pendingRequests:    syncext.NewAtomic[int](0), | ||||||
| 		triggerChan:        make(chan bool), | 		triggerChan:        make(chan bool), | ||||||
| 		cancelChan:         make(chan bool, 1), | 		cancelChan:         make(chan bool, 1), | ||||||
| 		execNowChan:        make(chan bool, 1), | 		execNowChan:        make(chan bool, 1), | ||||||
| 		lastRequestTime:    time.Now(), | 		lastRequestTime:    time.Now(), | ||||||
| 		initialRequestTime: time.Now(), | 		initialRequestTime: time.Now(), | ||||||
|  | 		onExecutionStart:   make([]func(bool), 0), | ||||||
|  | 		onExecutionDone:    make([]func(), 0), | ||||||
|  | 		onRequest:          make([]func(int, bool), 0), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -43,6 +59,11 @@ func (d *DelayedCombiningInvoker) Request() { | |||||||
|  |  | ||||||
| 	if d.executorRunning.Get() { | 	if d.executorRunning.Get() { | ||||||
| 		d.lastRequestTime = now | 		d.lastRequestTime = now | ||||||
|  | 		d.pendingRequests.Update(func(v int) int { return v + 1 }) | ||||||
|  |  | ||||||
|  | 		for _, fn := range d.onRequest { | ||||||
|  | 			_ = langext.RunPanicSafe(func() { fn(d.pendingRequests.Get(), true) }) | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		d.triggerChan <- true | 		d.triggerChan <- true | ||||||
| 	} else { | 	} else { | ||||||
| @@ -50,18 +71,28 @@ func (d *DelayedCombiningInvoker) Request() { | |||||||
| 		d.lastRequestTime = now | 		d.lastRequestTime = now | ||||||
|  |  | ||||||
| 		d.executorRunning.Set(true) | 		d.executorRunning.Set(true) | ||||||
|  | 		d.pendingRequests.Set(1) | ||||||
| 		syncext.ReadNonBlocking(d.triggerChan) // clear the channel | 		syncext.ReadNonBlocking(d.triggerChan) // clear the channel | ||||||
| 		syncext.ReadNonBlocking(d.cancelChan)  // clear the channel | 		syncext.ReadNonBlocking(d.cancelChan)  // clear the channel | ||||||
| 		syncext.ReadNonBlocking(d.execNowChan) // clear the channel | 		syncext.ReadNonBlocking(d.execNowChan) // clear the channel | ||||||
|  |  | ||||||
|  | 		for _, fn := range d.onRequest { | ||||||
|  | 			_ = langext.RunPanicSafe(func() { fn(d.pendingRequests.Get(), false) }) | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		go d.run() | 		go d.run() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (d *DelayedCombiningInvoker) run() { | func (d *DelayedCombiningInvoker) run() { | ||||||
|  |  | ||||||
|  | 	needsExecutorRunningCleanup := true | ||||||
| 	defer func() { | 	defer func() { | ||||||
| 		d.syncLock.Lock() | 		if needsExecutorRunningCleanup { | ||||||
| 		d.executorRunning.Set(false) | 			d.syncLock.Lock() | ||||||
| 		d.syncLock.Unlock() | 			d.executorRunning.Set(false) | ||||||
|  | 			d.syncLock.Unlock() | ||||||
|  | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| 	for { | 	for { | ||||||
| @@ -98,8 +129,25 @@ func (d *DelayedCombiningInvoker) run() { | |||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		d.pendingRequests.Set(0) | ||||||
|  |  | ||||||
|  | 		for _, fn := range d.onExecutionStart { | ||||||
|  | 			_ = langext.RunPanicSafe(func() { fn(immediately) }) | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// ================================================= | ||||||
| 		_ = langext.RunPanicSafe(d.action) | 		_ = langext.RunPanicSafe(d.action) | ||||||
|  | 		// ================================================= | ||||||
|  |  | ||||||
|  | 		d.executorRunning.Set(false) // ensure HasPendingRequests returns fals ein onExecutionDone listener | ||||||
|  | 		needsExecutorRunningCleanup = false | ||||||
|  |  | ||||||
|  | 		for _, fn := range d.onExecutionDone { | ||||||
|  | 			_ = langext.RunPanicSafe(fn) | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		d.syncLock.Unlock() | 		d.syncLock.Unlock() | ||||||
|  |  | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -115,6 +163,10 @@ func (d *DelayedCombiningInvoker) HasPendingRequests() bool { | |||||||
| 	return d.executorRunning.Get() | 	return d.executorRunning.Get() | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (d *DelayedCombiningInvoker) CountPendingRequests() int { | ||||||
|  | 	return d.pendingRequests.Get() | ||||||
|  | } | ||||||
|  |  | ||||||
| func (d *DelayedCombiningInvoker) ExecuteNow() bool { | func (d *DelayedCombiningInvoker) ExecuteNow() bool { | ||||||
| 	d.syncLock.Lock() | 	d.syncLock.Lock() | ||||||
| 	defer d.syncLock.Unlock() | 	defer d.syncLock.Unlock() | ||||||
| @@ -130,3 +182,21 @@ func (d *DelayedCombiningInvoker) ExecuteNow() bool { | |||||||
| func (d *DelayedCombiningInvoker) WaitForCompletion(ctx context.Context) error { | func (d *DelayedCombiningInvoker) WaitForCompletion(ctx context.Context) error { | ||||||
| 	return d.executorRunning.WaitWithContext(ctx, false) | 	return d.executorRunning.WaitWithContext(ctx, false) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (d *DelayedCombiningInvoker) RegisterOnExecutionStart(fn func(immediately bool)) { | ||||||
|  | 	d.syncLock.Lock() | ||||||
|  | 	defer d.syncLock.Unlock() | ||||||
|  | 	d.onExecutionStart = append(d.onExecutionStart, fn) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (d *DelayedCombiningInvoker) RegisterOnExecutionDone(fn func()) { | ||||||
|  | 	d.syncLock.Lock() | ||||||
|  | 	defer d.syncLock.Unlock() | ||||||
|  | 	d.onExecutionDone = append(d.onExecutionDone, fn) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (d *DelayedCombiningInvoker) RegisterOnRequest(fn func(pending int, initial bool)) { | ||||||
|  | 	d.syncLock.Lock() | ||||||
|  | 	defer d.syncLock.Unlock() | ||||||
|  | 	d.onRequest = append(d.onRequest, fn) | ||||||
|  | } | ||||||
|   | |||||||
| @@ -13,49 +13,49 @@ import ( | |||||||
| // PubSub is a simple Pub/Sub Broker | // PubSub is a simple Pub/Sub Broker | ||||||
| // Clients can subscribe to a namespace and receive published messages on this namespace | // Clients can subscribe to a namespace and receive published messages on this namespace | ||||||
| // Messages are broadcast to all subscribers | // Messages are broadcast to all subscribers | ||||||
| type PubSub[T any] struct { | type PubSub[TNamespace comparable, TData any] struct { | ||||||
| 	masterLock *sync.Mutex | 	masterLock *sync.Mutex | ||||||
|  |  | ||||||
| 	subscriptions map[string][]*pubSubSubscription[T] | 	subscriptions map[TNamespace][]*pubSubSubscription[TNamespace, TData] | ||||||
| } | } | ||||||
|  |  | ||||||
| type PubSubSubscription interface { | type PubSubSubscription interface { | ||||||
| 	Unsubscribe() | 	Unsubscribe() | ||||||
| } | } | ||||||
|  |  | ||||||
| type pubSubSubscription[T any] struct { | type pubSubSubscription[TNamespace comparable, TData any] struct { | ||||||
| 	ID string | 	ID string | ||||||
|  |  | ||||||
| 	parent    *PubSub[T] | 	parent    *PubSub[TNamespace, TData] | ||||||
| 	namespace string | 	namespace TNamespace | ||||||
|  |  | ||||||
| 	subLock *sync.Mutex | 	subLock *sync.Mutex | ||||||
|  |  | ||||||
| 	Func func(T) | 	Func func(TData) | ||||||
| 	Chan chan T | 	Chan chan TData | ||||||
|  |  | ||||||
| 	UnsubChan chan bool | 	UnsubChan chan bool | ||||||
| } | } | ||||||
|  |  | ||||||
| func (p *pubSubSubscription[T]) Unsubscribe() { | func (p *pubSubSubscription[TNamespace, TData]) Unsubscribe() { | ||||||
| 	p.parent.unsubscribe(p) | 	p.parent.unsubscribe(p) | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewPubSub[T any](capacity int) *PubSub[T] { | func NewPubSub[TNamespace comparable, TData any](capacity int) *PubSub[TNamespace, TData] { | ||||||
| 	return &PubSub[T]{ | 	return &PubSub[TNamespace, TData]{ | ||||||
| 		masterLock:    &sync.Mutex{}, | 		masterLock:    &sync.Mutex{}, | ||||||
| 		subscriptions: make(map[string][]*pubSubSubscription[T], capacity), | 		subscriptions: make(map[TNamespace][]*pubSubSubscription[TNamespace, TData], capacity), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) Namespaces() []string { | func (ps *PubSub[TNamespace, TData]) Namespaces() []TNamespace { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| 	return langext.MapKeyArr(ps.subscriptions) | 	return langext.MapKeyArr(ps.subscriptions) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) SubscriberCount(ns string) int { | func (ps *PubSub[TNamespace, TData]) SubscriberCount(ns TNamespace) int { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| @@ -64,7 +64,7 @@ func (ps *PubSub[T]) SubscriberCount(ns string) int { | |||||||
|  |  | ||||||
| // Publish sends `data` to all subscriber | // Publish sends `data` to all subscriber | ||||||
| // But unbuffered - if one is currently not listening, we skip (the actualReceiver < subscriber) | // But unbuffered - if one is currently not listening, we skip (the actualReceiver < subscriber) | ||||||
| func (ps *PubSub[T]) Publish(ns string, data T) (subscriber int, actualReceiver int) { | func (ps *PubSub[TNamespace, TData]) Publish(ns TNamespace, data TData) (subscriber int, actualReceiver int) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	subs := langext.ArrCopy(ps.subscriptions[ns]) | 	subs := langext.ArrCopy(ps.subscriptions[ns]) | ||||||
| 	ps.masterLock.Unlock() | 	ps.masterLock.Unlock() | ||||||
| @@ -94,7 +94,7 @@ func (ps *PubSub[T]) Publish(ns string, data T) (subscriber int, actualReceiver | |||||||
|  |  | ||||||
| // PublishWithContext sends `data` to all subscriber | // PublishWithContext sends `data` to all subscriber | ||||||
| // buffered - if one is currently not listening, we wait (but error out when the context runs out) | // buffered - if one is currently not listening, we wait (but error out when the context runs out) | ||||||
| func (ps *PubSub[T]) PublishWithContext(ctx context.Context, ns string, data T) (subscriber int, actualReceiver int, err error) { | func (ps *PubSub[TNamespace, TData]) PublishWithContext(ctx context.Context, ns TNamespace, data TData) (subscriber int, actualReceiver int, err error) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	subs := langext.ArrCopy(ps.subscriptions[ns]) | 	subs := langext.ArrCopy(ps.subscriptions[ns]) | ||||||
| 	ps.masterLock.Unlock() | 	ps.masterLock.Unlock() | ||||||
| @@ -134,7 +134,7 @@ func (ps *PubSub[T]) PublishWithContext(ctx context.Context, ns string, data T) | |||||||
|  |  | ||||||
| // PublishWithTimeout sends `data` to all subscriber | // PublishWithTimeout sends `data` to all subscriber | ||||||
| // buffered - if one is currently not listening, we wait (but wait at most `timeout` - if the timeout is exceeded then actualReceiver < subscriber) | // buffered - if one is currently not listening, we wait (but wait at most `timeout` - if the timeout is exceeded then actualReceiver < subscriber) | ||||||
| func (ps *PubSub[T]) PublishWithTimeout(ns string, data T, timeout time.Duration) (subscriber int, actualReceiver int) { | func (ps *PubSub[TNamespace, TData]) PublishWithTimeout(ns TNamespace, data TData, timeout time.Duration) (subscriber int, actualReceiver int) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	subs := langext.ArrCopy(ps.subscriptions[ns]) | 	subs := langext.ArrCopy(ps.subscriptions[ns]) | ||||||
| 	ps.masterLock.Unlock() | 	ps.masterLock.Unlock() | ||||||
| @@ -162,42 +162,42 @@ func (ps *PubSub[T]) PublishWithTimeout(ns string, data T, timeout time.Duration | |||||||
| 	return subscriber, actualReceiver | 	return subscriber, actualReceiver | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) SubscribeByCallback(ns string, fn func(T)) PubSubSubscription { | func (ps *PubSub[TNamespace, TData]) SubscribeByCallback(ns TNamespace, fn func(TData)) PubSubSubscription { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| 	sub := &pubSubSubscription[T]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Func: fn, UnsubChan: nil} | 	sub := &pubSubSubscription[TNamespace, TData]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Func: fn, UnsubChan: nil} | ||||||
|  |  | ||||||
| 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | ||||||
|  |  | ||||||
| 	return sub | 	return sub | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) SubscribeByChan(ns string, chanBufferSize int) (chan T, PubSubSubscription) { | func (ps *PubSub[TNamespace, TData]) SubscribeByChan(ns TNamespace, chanBufferSize int) (chan TData, PubSubSubscription) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| 	msgCh := make(chan T, chanBufferSize) | 	msgCh := make(chan TData, chanBufferSize) | ||||||
|  |  | ||||||
| 	sub := &pubSubSubscription[T]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: nil} | 	sub := &pubSubSubscription[TNamespace, TData]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: nil} | ||||||
|  |  | ||||||
| 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | ||||||
|  |  | ||||||
| 	return msgCh, sub | 	return msgCh, sub | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) SubscribeByIter(ns string, chanBufferSize int) (iter.Seq[T], PubSubSubscription) { | func (ps *PubSub[TNamespace, TData]) SubscribeByIter(ns TNamespace, chanBufferSize int) (iter.Seq[TData], PubSubSubscription) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| 	msgCh := make(chan T, chanBufferSize) | 	msgCh := make(chan TData, chanBufferSize) | ||||||
| 	unsubChan := make(chan bool, 8) | 	unsubChan := make(chan bool, 8) | ||||||
|  |  | ||||||
| 	sub := &pubSubSubscription[T]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: unsubChan} | 	sub := &pubSubSubscription[TNamespace, TData]{ID: xid.New().String(), namespace: ns, parent: ps, subLock: &sync.Mutex{}, Chan: msgCh, UnsubChan: unsubChan} | ||||||
|  |  | ||||||
| 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | 	ps.subscriptions[ns] = append(ps.subscriptions[ns], sub) | ||||||
|  |  | ||||||
| 	iterFun := func(yield func(T) bool) { | 	iterFun := func(yield func(TData) bool) { | ||||||
| 		for { | 		for { | ||||||
| 			select { | 			select { | ||||||
| 			case msg := <-msgCh: | 			case msg := <-msgCh: | ||||||
| @@ -215,7 +215,7 @@ func (ps *PubSub[T]) SubscribeByIter(ns string, chanBufferSize int) (iter.Seq[T] | |||||||
| 	return iterFun, sub | 	return iterFun, sub | ||||||
| } | } | ||||||
|  |  | ||||||
| func (ps *PubSub[T]) unsubscribe(p *pubSubSubscription[T]) { | func (ps *PubSub[TNamespace, TData]) unsubscribe(p *pubSubSubscription[TNamespace, TData]) { | ||||||
| 	ps.masterLock.Lock() | 	ps.masterLock.Lock() | ||||||
| 	defer ps.masterLock.Unlock() | 	defer ps.masterLock.Unlock() | ||||||
|  |  | ||||||
| @@ -232,7 +232,7 @@ func (ps *PubSub[T]) unsubscribe(p *pubSubSubscription[T]) { | |||||||
| 		p.UnsubChan = nil | 		p.UnsubChan = nil | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ps.subscriptions[p.namespace] = langext.ArrFilter(ps.subscriptions[p.namespace], func(v *pubSubSubscription[T]) bool { | 	ps.subscriptions[p.namespace] = langext.ArrFilter(ps.subscriptions[p.namespace], func(v *pubSubSubscription[TNamespace, TData]) bool { | ||||||
| 		return v.ID != p.ID | 		return v.ID != p.ID | ||||||
| 	}) | 	}) | ||||||
| 	if len(ps.subscriptions[p.namespace]) == 0 { | 	if len(ps.subscriptions[p.namespace]) == 0 { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func TestNewPubSub(t *testing.T) { | func TestNewPubSub(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
| 	if ps == nil { | 	if ps == nil { | ||||||
| 		t.Fatal("NewPubSub returned nil") | 		t.Fatal("NewPubSub returned nil") | ||||||
| 	} | 	} | ||||||
| @@ -21,7 +21,7 @@ func TestNewPubSub(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_Namespaces(t *testing.T) { | func TestPubSub_Namespaces(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Initially no namespaces | 	// Initially no namespaces | ||||||
| 	namespaces := ps.Namespaces() | 	namespaces := ps.Namespaces() | ||||||
| @@ -60,7 +60,7 @@ func TestPubSub_Namespaces(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_SubscribeByCallback(t *testing.T) { | func TestPubSub_SubscribeByCallback(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	var received string | 	var received string | ||||||
| 	var wg sync.WaitGroup | 	var wg sync.WaitGroup | ||||||
| @@ -94,7 +94,7 @@ func TestPubSub_SubscribeByCallback(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_SubscribeByChan(t *testing.T) { | func TestPubSub_SubscribeByChan(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	ch, sub := ps.SubscribeByChan("test-ns", 1) | 	ch, sub := ps.SubscribeByChan("test-ns", 1) | ||||||
| 	defer sub.Unsubscribe() | 	defer sub.Unsubscribe() | ||||||
| @@ -122,7 +122,7 @@ func TestPubSub_SubscribeByChan(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_SubscribeByIter(t *testing.T) { | func TestPubSub_SubscribeByIter(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	iterSeq, sub := ps.SubscribeByIter("test-ns", 1) | 	iterSeq, sub := ps.SubscribeByIter("test-ns", 1) | ||||||
| 	defer sub.Unsubscribe() | 	defer sub.Unsubscribe() | ||||||
| @@ -165,7 +165,7 @@ func TestPubSub_SubscribeByIter(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_Publish(t *testing.T) { | func TestPubSub_Publish(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Test publishing to a namespace with no subscribers | 	// Test publishing to a namespace with no subscribers | ||||||
| 	subs, receivers := ps.Publish("empty-ns", "hello") | 	subs, receivers := ps.Publish("empty-ns", "hello") | ||||||
| @@ -215,7 +215,7 @@ func TestPubSub_Publish(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_PublishWithTimeout(t *testing.T) { | func TestPubSub_PublishWithTimeout(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Add a subscriber with a channel | 	// Add a subscriber with a channel | ||||||
| 	ch, sub := ps.SubscribeByChan("test-ns", 1) | 	ch, sub := ps.SubscribeByChan("test-ns", 1) | ||||||
| @@ -262,7 +262,7 @@ func TestPubSub_PublishWithTimeout(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_PublishWithContext(t *testing.T) { | func TestPubSub_PublishWithContext(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Add a subscriber with a channel | 	// Add a subscriber with a channel | ||||||
| 	ch, sub := ps.SubscribeByChan("test-ns", 1) | 	ch, sub := ps.SubscribeByChan("test-ns", 1) | ||||||
| @@ -328,7 +328,7 @@ func TestPubSub_PublishWithContext(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_Unsubscribe(t *testing.T) { | func TestPubSub_Unsubscribe(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Add a subscriber | 	// Add a subscriber | ||||||
| 	ch, sub := ps.SubscribeByChan("test-ns", 1) | 	ch, sub := ps.SubscribeByChan("test-ns", 1) | ||||||
| @@ -372,7 +372,7 @@ func TestPubSub_Unsubscribe(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestPubSub_MultipleSubscribers(t *testing.T) { | func TestPubSub_MultipleSubscribers(t *testing.T) { | ||||||
| 	ps := NewPubSub[string](10) | 	ps := NewPubSub[string, string](10) | ||||||
|  |  | ||||||
| 	// Add multiple subscribers | 	// Add multiple subscribers | ||||||
| 	ch1, sub1 := ps.SubscribeByChan("test-ns", 1) | 	ch1, sub1 := ps.SubscribeByChan("test-ns", 1) | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ package dataext | |||||||
|  |  | ||||||
| import "sync" | import "sync" | ||||||
|  |  | ||||||
|  | // SyncMap is a thread-safe map implementation for generic key-value pairs. | ||||||
|  | // All functions aresafe to be called in parallel. | ||||||
| type SyncMap[TKey comparable, TData any] struct { | type SyncMap[TKey comparable, TData any] struct { | ||||||
| 	data map[TKey]TData | 	data map[TKey]TData | ||||||
| 	lock sync.Mutex | 	lock sync.Mutex | ||||||
| @@ -11,6 +13,7 @@ func NewSyncMap[TKey comparable, TData any]() *SyncMap[TKey, TData] { | |||||||
| 	return &SyncMap[TKey, TData]{data: make(map[TKey]TData), lock: sync.Mutex{}} | 	return &SyncMap[TKey, TData]{data: make(map[TKey]TData), lock: sync.Mutex{}} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Set sets the value for the provided key | ||||||
| func (s *SyncMap[TKey, TData]) Set(key TKey, data TData) { | func (s *SyncMap[TKey, TData]) Set(key TKey, data TData) { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -22,6 +25,7 @@ func (s *SyncMap[TKey, TData]) Set(key TKey, data TData) { | |||||||
| 	s.data[key] = data | 	s.data[key] = data | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // SetIfNotContains sets the value for the provided key if it does not already exist | ||||||
| func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool { | func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -39,6 +43,7 @@ func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool { | |||||||
| 	return true | 	return true | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // SetIfNotContainsFunc sets the value for the provided key using the provided function | ||||||
| func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) bool { | func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) bool { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -56,6 +61,7 @@ func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) | |||||||
| 	return true | 	return true | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Get retrieves the value for the provided key | ||||||
| func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool) { | func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool) { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -71,6 +77,8 @@ func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetAndSetIfNotContains returns the existing value if the key exists. | ||||||
|  | // Otherwise, it sets the provided value and returns it. | ||||||
| func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TData { | func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TData { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -87,6 +95,8 @@ func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TDat | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetAndSetIfNotContainsFunc returns the existing value if the key exists. | ||||||
|  | // Otherwise, it calls the provided function to generate the value, sets it, and returns it. | ||||||
| func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData { | func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -104,6 +114,7 @@ func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Delete removes the entry with the provided key and returns true if the key existed before. | ||||||
| func (s *SyncMap[TKey, TData]) Delete(key TKey) bool { | func (s *SyncMap[TKey, TData]) Delete(key TKey) bool { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -119,6 +130,7 @@ func (s *SyncMap[TKey, TData]) Delete(key TKey) bool { | |||||||
| 	return ok | 	return ok | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // DeleteIf deletes all entries that match the provided function and returns the number of removed entries. | ||||||
| func (s *SyncMap[TKey, TData]) DeleteIf(fn func(key TKey, data TData) bool) int { | func (s *SyncMap[TKey, TData]) DeleteIf(fn func(key TKey, data TData) bool) int { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -138,6 +150,42 @@ func (s *SyncMap[TKey, TData]) DeleteIf(fn func(key TKey, data TData) bool) int | |||||||
| 	return rm | 	return rm | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // UpdateIfExists updates the value if the key exists, otherwise it does nothing. | ||||||
|  | func (s *SyncMap[TKey, TData]) UpdateIfExists(key TKey, fn func(data TData) TData) bool { | ||||||
|  | 	s.lock.Lock() | ||||||
|  | 	defer s.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	if s.data == nil { | ||||||
|  | 		s.data = make(map[TKey]TData) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if v, ok := s.data[key]; ok { | ||||||
|  | 		s.data[key] = fn(v) | ||||||
|  | 		return true | ||||||
|  | 	} else { | ||||||
|  | 		return false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // UpdateOrInsert updates the value if the key exists, otherwise it inserts the provided `insertValue`. | ||||||
|  | func (s *SyncMap[TKey, TData]) UpdateOrInsert(key TKey, fn func(data TData) TData, insertValue TData) bool { | ||||||
|  | 	s.lock.Lock() | ||||||
|  | 	defer s.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	if s.data == nil { | ||||||
|  | 		s.data = make(map[TKey]TData) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if v, ok := s.data[key]; ok { | ||||||
|  | 		s.data[key] = fn(v) | ||||||
|  | 		return true | ||||||
|  | 	} else { | ||||||
|  | 		s.data[key] = insertValue | ||||||
|  | 		return false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Clear removes all entries from the map. | ||||||
| func (s *SyncMap[TKey, TData]) Clear() { | func (s *SyncMap[TKey, TData]) Clear() { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -145,6 +193,7 @@ func (s *SyncMap[TKey, TData]) Clear() { | |||||||
| 	s.data = make(map[TKey]TData) | 	s.data = make(map[TKey]TData) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Contains checks if the map contains the provided key. | ||||||
| func (s *SyncMap[TKey, TData]) Contains(key TKey) bool { | func (s *SyncMap[TKey, TData]) Contains(key TKey) bool { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -158,6 +207,7 @@ func (s *SyncMap[TKey, TData]) Contains(key TKey) bool { | |||||||
| 	return ok | 	return ok | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetAllKeys returns a copy (!) of all keys in the map. | ||||||
| func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey { | func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -175,6 +225,7 @@ func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey { | |||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetAllValues returns a copy (!) of all values in the map. | ||||||
| func (s *SyncMap[TKey, TData]) GetAllValues() []TData { | func (s *SyncMap[TKey, TData]) GetAllValues() []TData { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
| @@ -192,6 +243,7 @@ func (s *SyncMap[TKey, TData]) GetAllValues() []TData { | |||||||
| 	return r | 	return r | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Count returns the number of entries in the map. | ||||||
| func (s *SyncMap[TKey, TData]) Count() int { | func (s *SyncMap[TKey, TData]) Count() int { | ||||||
| 	s.lock.Lock() | 	s.lock.Lock() | ||||||
| 	defer s.lock.Unlock() | 	defer s.lock.Unlock() | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package enums | package enums | ||||||
|  |  | ||||||
|  | import "encoding/json" | ||||||
|  |  | ||||||
| type Enum interface { | type Enum interface { | ||||||
| 	Valid() bool | 	Valid() bool | ||||||
| 	ValuesAny() []any | 	ValuesAny() []any | ||||||
| @@ -31,3 +33,25 @@ type EnumDescriptionMetaValue struct { | |||||||
| 	Value       Enum   `json:"value"` | 	Value       Enum   `json:"value"` | ||||||
| 	Description string `json:"description"` | 	Description string `json:"description"` | ||||||
| } | } | ||||||
|  |  | ||||||
|  | type EnumDataMetaValue struct { | ||||||
|  | 	VarName     string  `json:"varName"` | ||||||
|  | 	Value       Enum    `json:"value"` | ||||||
|  | 	Description *string `json:"description"` | ||||||
|  |  | ||||||
|  | 	Data map[string]any `json:"-"` //handled by MarshalJSON | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (v EnumDataMetaValue) MarshalJSON() ([]byte, error) { | ||||||
|  | 	m := make(map[string]any, 8) | ||||||
|  |  | ||||||
|  | 	for k, dv := range v.Data { | ||||||
|  | 		m[k] = dv | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	m["varName"] = v.VarName | ||||||
|  | 	m["value"] = v.Value | ||||||
|  | 	m["description"] = v.Description | ||||||
|  |  | ||||||
|  | 	return json.Marshal(m) | ||||||
|  | } | ||||||
|   | |||||||
| @@ -5,17 +5,18 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"net/http" | ||||||
|  | 	"os" | ||||||
|  | 	"runtime/debug" | ||||||
|  | 	"strings" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/dataext" | 	"git.blackforestbytes.com/BlackForestBytes/goext/dataext" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/enums" | 	"git.blackforestbytes.com/BlackForestBytes/goext/enums" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
| 	"github.com/gin-gonic/gin" | 	"github.com/gin-gonic/gin" | ||||||
| 	"github.com/rs/zerolog" | 	"github.com/rs/zerolog" | ||||||
| 	"go.mongodb.org/mongo-driver/bson/primitive" | 	"go.mongodb.org/mongo-driver/bson/primitive" | ||||||
| 	"net/http" |  | ||||||
| 	"os" |  | ||||||
| 	"runtime/debug" |  | ||||||
| 	"strings" |  | ||||||
| 	"time" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // | // | ||||||
| @@ -430,12 +431,22 @@ func (b *Builder) BuildAsExerr(ctxs ...context.Context) *ExErr { | |||||||
| 		return FromError(b.wrappedErr) | 		return FromError(b.wrappedErr) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if pkgconfig.ZeroLogErrTraces && !b.noLog && (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) { | 	if pkgconfig.ZeroLogErrTraces && !b.noLog { | ||||||
| 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Error()) | 		if b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal { | ||||||
| 	} else if pkgconfig.ZeroLogAllTraces && !b.noLog { | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Error()) | ||||||
| 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Error()) | 		} else if b.errorData.Severity == SevWarn { | ||||||
| 	} | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Warn()) | ||||||
|  | 		} else if b.errorData.Severity == SevInfo { | ||||||
|  | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Info()) | ||||||
|  | 		} else if b.errorData.Severity == SevDebug { | ||||||
|  | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Debug()) | ||||||
|  | 		} else if b.errorData.Severity == SevTrace { | ||||||
|  | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Trace()) | ||||||
|  | 		} else { | ||||||
|  | 			b.errorData.ShortLog(pkgconfig.ZeroLogger.Error()) // ?!? unknown severity | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 	} | ||||||
| 	b.errorData.CallListener(MethodBuild, ListenerOpt{NoLog: b.noLog}) | 	b.errorData.CallListener(MethodBuild, ListenerOpt{NoLog: b.noLog}) | ||||||
|  |  | ||||||
| 	return b.errorData | 	return b.errorData | ||||||
| @@ -456,10 +467,19 @@ func (b *Builder) Output(ctx context.Context, g *gin.Context) { | |||||||
|  |  | ||||||
| 	// this is only here to add one level to the trace | 	// this is only here to add one level to the trace | ||||||
| 	// so that .Build() and .Output() and .Print() have the same depth and our stack-skip logger can have the same skip-count | 	// so that .Build() and .Output() and .Print() have the same depth and our stack-skip logger can have the same skip-count | ||||||
| 	b.doOutput(ctx, g) | 	b.doGinOutput(ctx, g) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (b *Builder) doOutput(ctx context.Context, g *gin.Context) { | // OutputRaw works teh same as Output() - but does not depend on gin and works with a raw http.ResponseWriter | ||||||
|  | func (b *Builder) OutputRaw(w http.ResponseWriter) { | ||||||
|  | 	warnOnPkgConfigNotInitialized() | ||||||
|  |  | ||||||
|  | 	// this is only here to add one level to the trace | ||||||
|  | 	// so that .Build() and .Output() and .Print() have the same depth and our stack-skip logger can have the same skip-count | ||||||
|  | 	b.doRawOutput(w) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (b *Builder) doGinOutput(ctx context.Context, g *gin.Context) { | ||||||
| 	b.errorData.Output(g) | 	b.errorData.Output(g) | ||||||
|  |  | ||||||
| 	if (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) && (pkgconfig.ZeroLogErrGinOutput || pkgconfig.ZeroLogAllGinOutput) { | 	if (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) && (pkgconfig.ZeroLogErrGinOutput || pkgconfig.ZeroLogAllGinOutput) { | ||||||
| @@ -471,6 +491,18 @@ func (b *Builder) doOutput(ctx context.Context, g *gin.Context) { | |||||||
| 	b.errorData.CallListener(MethodOutput, ListenerOpt{NoLog: b.noLog}) | 	b.errorData.CallListener(MethodOutput, ListenerOpt{NoLog: b.noLog}) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (b *Builder) doRawOutput(w http.ResponseWriter) { | ||||||
|  | 	b.errorData.OutputRaw(w) | ||||||
|  |  | ||||||
|  | 	if (b.errorData.Severity == SevErr || b.errorData.Severity == SevFatal) && (pkgconfig.ZeroLogErrGinOutput || pkgconfig.ZeroLogAllGinOutput) { | ||||||
|  | 		b.errorData.Log(pkgconfig.ZeroLogger.Error()) | ||||||
|  | 	} else if (b.errorData.Severity == SevWarn) && (pkgconfig.ZeroLogAllGinOutput) { | ||||||
|  | 		b.errorData.Log(pkgconfig.ZeroLogger.Warn()) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	b.errorData.CallListener(MethodOutput, ListenerOpt{NoLog: b.noLog}) | ||||||
|  | } | ||||||
|  |  | ||||||
| // Print prints the error | // Print prints the error | ||||||
| // If the error is SevErr we also send it to the error-service | // If the error is SevErr we also send it to the error-service | ||||||
| func (b *Builder) Print(ctxs ...context.Context) Proxy { | func (b *Builder) Print(ctxs ...context.Context) Proxy { | ||||||
| @@ -492,8 +524,12 @@ func (b *Builder) doPrint() Proxy { | |||||||
| 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Warn()) | 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Warn()) | ||||||
| 	} else if b.errorData.Severity == SevInfo { | 	} else if b.errorData.Severity == SevInfo { | ||||||
| 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Info()) | 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Info()) | ||||||
| 	} else { | 	} else if b.errorData.Severity == SevDebug { | ||||||
| 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Debug()) | 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Debug()) | ||||||
|  | 	} else if b.errorData.Severity == SevTrace { | ||||||
|  | 		b.errorData.ShortLog(pkgconfig.ZeroLogger.Trace()) | ||||||
|  | 	} else { | ||||||
|  | 		b.errorData.Log(pkgconfig.ZeroLogger.Error()) // ?!? unknown severity | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	b.errorData.CallListener(MethodPrint, ListenerOpt{NoLog: b.noLog}) | 	b.errorData.CallListener(MethodPrint, ListenerOpt{NoLog: b.noLog}) | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								exerr/gin.go
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								exerr/gin.go
									
									
									
									
									
								
							| @@ -1,9 +1,9 @@ | |||||||
| package exerr | package exerr | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"github.com/gin-gonic/gin" |  | ||||||
| 	json "git.blackforestbytes.com/BlackForestBytes/goext/gojson" | 	json "git.blackforestbytes.com/BlackForestBytes/goext/gojson" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
| @@ -68,7 +68,6 @@ func (ee *ExErr) ToDefaultAPIJson() (string, error) { | |||||||
| 	gjr := json.GoJsonRender{Data: ee.ToAPIJson(true, pkgconfig.ExtendedGinOutput, pkgconfig.IncludeMetaInGinOutput), NilSafeSlices: true, NilSafeMaps: true} | 	gjr := json.GoJsonRender{Data: ee.ToAPIJson(true, pkgconfig.ExtendedGinOutput, pkgconfig.IncludeMetaInGinOutput), NilSafeSlices: true, NilSafeMaps: true} | ||||||
|  |  | ||||||
| 	r, err := gjr.RenderString() | 	r, err := gjr.RenderString() | ||||||
|  |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
| @@ -143,3 +142,34 @@ func (ee *ExErr) Output(g *gin.Context) { | |||||||
|  |  | ||||||
| 	g.Render(statuscode, json.GoJsonRender{Data: ginOutput, NilSafeSlices: true, NilSafeMaps: true}) | 	g.Render(statuscode, json.GoJsonRender{Data: ginOutput, NilSafeSlices: true, NilSafeMaps: true}) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (ee *ExErr) OutputRaw(w http.ResponseWriter) { | ||||||
|  |  | ||||||
|  | 	warnOnPkgConfigNotInitialized() | ||||||
|  |  | ||||||
|  | 	var statuscode = http.StatusInternalServerError | ||||||
|  |  | ||||||
|  | 	var baseCat = ee.RecursiveCategory() | ||||||
|  | 	var baseType = ee.RecursiveType() | ||||||
|  | 	var baseStatuscode = ee.RecursiveStatuscode() | ||||||
|  |  | ||||||
|  | 	if baseCat == CatUser { | ||||||
|  | 		statuscode = http.StatusBadRequest | ||||||
|  | 	} else if baseCat == CatSystem { | ||||||
|  | 		statuscode = http.StatusInternalServerError | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if baseStatuscode != nil { | ||||||
|  | 		statuscode = *ee.StatusCode | ||||||
|  | 	} else if baseType.DefaultStatusCode != nil { | ||||||
|  | 		statuscode = *baseType.DefaultStatusCode | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	ginOutput, err := ee.ToDefaultAPIJson() | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) // cannot happen | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	w.WriteHeader(statuscode) | ||||||
|  | 	_, _ = w.Write([]byte(ginOutput)) | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								go.mod
									
									
									
									
									
								
							| @@ -1,40 +1,40 @@ | |||||||
| module git.blackforestbytes.com/BlackForestBytes/goext | module git.blackforestbytes.com/BlackForestBytes/goext | ||||||
|  |  | ||||||
| go 1.23.0 | go 1.24.0 | ||||||
|  |  | ||||||
| toolchain go1.24.0 |  | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
| 	github.com/gin-gonic/gin v1.10.1 | 	github.com/gin-gonic/gin v1.11.0 | ||||||
| 	github.com/glebarez/go-sqlite v1.22.0 // only needed for tests -.- | 	github.com/glebarez/go-sqlite v1.22.0 // only needed for tests -.- | ||||||
| 	github.com/jmoiron/sqlx v1.4.0 | 	github.com/jmoiron/sqlx v1.4.0 | ||||||
| 	github.com/rs/xid v1.6.0 | 	github.com/rs/xid v1.6.0 | ||||||
| 	github.com/rs/zerolog v1.34.0 | 	github.com/rs/zerolog v1.34.0 | ||||||
| 	go.mongodb.org/mongo-driver v1.17.4 | 	go.mongodb.org/mongo-driver v1.17.4 | ||||||
| 	golang.org/x/crypto v0.40.0 | 	golang.org/x/crypto v0.42.0 | ||||||
| 	golang.org/x/sys v0.34.0 | 	golang.org/x/sys v0.36.0 | ||||||
| 	golang.org/x/term v0.33.0 | 	golang.org/x/term v0.35.0 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
| 	github.com/disintegration/imaging v1.6.2 | 	github.com/disintegration/imaging v1.6.2 | ||||||
| 	github.com/jung-kurt/gofpdf v1.16.2 | 	github.com/jung-kurt/gofpdf v1.16.2 | ||||||
| 	golang.org/x/net v0.42.0 | 	golang.org/x/net v0.44.0 | ||||||
| 	golang.org/x/sync v0.16.0 | 	golang.org/x/sync v0.17.0 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
| 	github.com/bytedance/sonic v1.13.3 // indirect | 	github.com/bytedance/gopkg v0.1.3 // indirect | ||||||
|  | 	github.com/bytedance/sonic v1.14.1 // indirect | ||||||
| 	github.com/bytedance/sonic/loader v0.3.0 // indirect | 	github.com/bytedance/sonic/loader v0.3.0 // indirect | ||||||
| 	github.com/cloudwego/base64x v0.1.5 // indirect | 	github.com/cloudwego/base64x v0.1.6 // indirect | ||||||
| 	github.com/cloudwego/iasm v0.2.0 // indirect | 	github.com/cloudwego/iasm v0.2.0 // indirect | ||||||
| 	github.com/dustin/go-humanize v1.0.1 // indirect | 	github.com/dustin/go-humanize v1.0.1 // indirect | ||||||
| 	github.com/gabriel-vasile/mimetype v1.4.9 // indirect | 	github.com/gabriel-vasile/mimetype v1.4.10 // indirect | ||||||
| 	github.com/gin-contrib/sse v1.1.0 // indirect | 	github.com/gin-contrib/sse v1.1.0 // indirect | ||||||
| 	github.com/go-playground/locales v0.14.1 // indirect | 	github.com/go-playground/locales v0.14.1 // indirect | ||||||
| 	github.com/go-playground/universal-translator v0.18.1 // indirect | 	github.com/go-playground/universal-translator v0.18.1 // indirect | ||||||
| 	github.com/go-playground/validator/v10 v10.27.0 // indirect | 	github.com/go-playground/validator/v10 v10.27.0 // indirect | ||||||
| 	github.com/goccy/go-json v0.10.5 // indirect | 	github.com/goccy/go-json v0.10.5 // indirect | ||||||
|  | 	github.com/goccy/go-yaml v1.18.0 // indirect | ||||||
| 	github.com/golang/snappy v1.0.0 // indirect | 	github.com/golang/snappy v1.0.0 // indirect | ||||||
| 	github.com/google/uuid v1.5.0 // indirect | 	github.com/google/uuid v1.5.0 // indirect | ||||||
| 	github.com/json-iterator/go v1.1.12 // indirect | 	github.com/json-iterator/go v1.1.12 // indirect | ||||||
| @@ -47,6 +47,8 @@ require ( | |||||||
| 	github.com/modern-go/reflect2 v1.0.2 // indirect | 	github.com/modern-go/reflect2 v1.0.2 // indirect | ||||||
| 	github.com/montanaflynn/stats v0.7.1 // indirect | 	github.com/montanaflynn/stats v0.7.1 // indirect | ||||||
| 	github.com/pelletier/go-toml/v2 v2.2.4 // indirect | 	github.com/pelletier/go-toml/v2 v2.2.4 // indirect | ||||||
|  | 	github.com/quic-go/qpack v0.5.1 // indirect | ||||||
|  | 	github.com/quic-go/quic-go v0.55.0 // indirect | ||||||
| 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||||||
| 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | ||||||
| 	github.com/ugorji/go/codec v1.3.0 // indirect | 	github.com/ugorji/go/codec v1.3.0 // indirect | ||||||
| @@ -54,10 +56,13 @@ require ( | |||||||
| 	github.com/xdg-go/scram v1.1.2 // indirect | 	github.com/xdg-go/scram v1.1.2 // indirect | ||||||
| 	github.com/xdg-go/stringprep v1.0.4 // indirect | 	github.com/xdg-go/stringprep v1.0.4 // indirect | ||||||
| 	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect | 	github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect | ||||||
| 	golang.org/x/arch v0.19.0 // indirect | 	go.uber.org/mock v0.6.0 // indirect | ||||||
| 	golang.org/x/image v0.29.0 // indirect | 	golang.org/x/arch v0.21.0 // indirect | ||||||
| 	golang.org/x/text v0.27.0 // indirect | 	golang.org/x/image v0.31.0 // indirect | ||||||
| 	google.golang.org/protobuf v1.36.6 // indirect | 	golang.org/x/mod v0.28.0 // indirect | ||||||
|  | 	golang.org/x/text v0.29.0 // indirect | ||||||
|  | 	golang.org/x/tools v0.37.0 // indirect | ||||||
|  | 	google.golang.org/protobuf v1.36.10 // indirect | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||||
| 	modernc.org/libc v1.37.6 // indirect | 	modernc.org/libc v1.37.6 // indirect | ||||||
| 	modernc.org/mathutil v1.6.0 // indirect | 	modernc.org/mathutil v1.6.0 // indirect | ||||||
|   | |||||||
							
								
								
									
										66
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										66
									
								
								go.sum
									
									
									
									
									
								
							| @@ -1,6 +1,8 @@ | |||||||
| filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= | filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= | ||||||
| filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= | filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= | ||||||
| github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= | github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= | ||||||
|  | github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= | ||||||
|  | github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= | ||||||
| github.com/bytedance/sonic v1.12.3 h1:W2MGa7RCU1QTeYRTPE3+88mVC0yXmsRQRChiyVocVjU= | github.com/bytedance/sonic v1.12.3 h1:W2MGa7RCU1QTeYRTPE3+88mVC0yXmsRQRChiyVocVjU= | ||||||
| github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= | github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= | ||||||
| github.com/bytedance/sonic v1.12.4 h1:9Csb3c9ZJhfUWeMtpCDCq6BUoH5ogfDFLUgQ/jG+R0k= | github.com/bytedance/sonic v1.12.4 h1:9Csb3c9ZJhfUWeMtpCDCq6BUoH5ogfDFLUgQ/jG+R0k= | ||||||
| @@ -23,6 +25,10 @@ github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqp | |||||||
| github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= | github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= | ||||||
| github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= | github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= | ||||||
| github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= | github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= | ||||||
|  | github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ= | ||||||
|  | github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA= | ||||||
|  | github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w= | ||||||
|  | github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc= | ||||||
| github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= | github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= | ||||||
| github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= | github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= | ||||||
| github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= | github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= | ||||||
| @@ -40,6 +46,8 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/ | |||||||
| github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= | github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= | ||||||
| github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= | github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= | ||||||
| github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= | github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= | ||||||
|  | github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= | ||||||
|  | github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= | ||||||
| github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= | github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= | ||||||
| github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= | github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= | ||||||
| github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | ||||||
| @@ -60,6 +68,8 @@ github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3G | |||||||
| github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= | github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= | ||||||
| github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= | github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= | ||||||
| github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= | github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= | ||||||
|  | github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0= | ||||||
|  | github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= | ||||||
| github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= | ||||||
| github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= | ||||||
| github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E= | github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E= | ||||||
| @@ -70,6 +80,8 @@ github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= | |||||||
| github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= | github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= | ||||||
| github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ= | github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ= | ||||||
| github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= | github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= | ||||||
|  | github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk= | ||||||
|  | github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls= | ||||||
| github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= | github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= | ||||||
| github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= | github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= | ||||||
| github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= | github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= | ||||||
| @@ -98,6 +110,8 @@ github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM= | |||||||
| github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= | github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= | ||||||
| github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= | github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= | ||||||
| github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= | github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= | ||||||
|  | github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= | ||||||
|  | github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= | ||||||
| github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | ||||||
| github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= | github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= | ||||||
| github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= | ||||||
| @@ -165,6 +179,14 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE | |||||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
|  | github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= | ||||||
|  | github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= | ||||||
|  | github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg= | ||||||
|  | github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY= | ||||||
|  | github.com/quic-go/quic-go v0.54.1 h1:4ZAWm0AhCb6+hE+l5Q1NAL0iRn/ZrMwqHRGQiFwj2eg= | ||||||
|  | github.com/quic-go/quic-go v0.54.1/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY= | ||||||
|  | github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk= | ||||||
|  | github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U= | ||||||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= | ||||||
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= | ||||||
| github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= | github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= | ||||||
| @@ -214,6 +236,8 @@ go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeH | |||||||
| go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= | go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= | ||||||
| go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= | go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= | ||||||
| go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= | go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= | ||||||
|  | go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= | ||||||
|  | go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= | ||||||
| golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= | golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= | ||||||
| golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= | golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= | ||||||
| golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg= | golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg= | ||||||
| @@ -232,6 +256,10 @@ golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc= | |||||||
| golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= | golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= | ||||||
| golang.org/x/arch v0.19.0 h1:LmbDQUodHThXE+htjrnmVD73M//D9GTH6wFZjyDkjyU= | golang.org/x/arch v0.19.0 h1:LmbDQUodHThXE+htjrnmVD73M//D9GTH6wFZjyDkjyU= | ||||||
| golang.org/x/arch v0.19.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= | golang.org/x/arch v0.19.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= | ||||||
|  | golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c= | ||||||
|  | golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= | ||||||
|  | golang.org/x/arch v0.21.0 h1:iTC9o7+wP6cPWpDWkivCvQFGAHDQ59SrSxsLPcnkArw= | ||||||
|  | golang.org/x/arch v0.21.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= | ||||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||||
| golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||||||
| golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= | golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= | ||||||
| @@ -258,6 +286,10 @@ golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= | |||||||
| golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= | golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= | ||||||
| golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= | golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= | ||||||
| golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= | golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= | ||||||
|  | golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= | ||||||
|  | golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= | ||||||
|  | golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= | ||||||
|  | golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= | ||||||
| golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||||||
| golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= | ||||||
| golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s= | golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s= | ||||||
| @@ -278,7 +310,13 @@ golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE= | |||||||
| golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY= | golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY= | ||||||
| golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas= | golang.org/x/image v0.29.0 h1:HcdsyR4Gsuys/Axh0rDEmlBmB68rW1U9BUdB3UVHsas= | ||||||
| golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA= | golang.org/x/image v0.29.0/go.mod h1:RVJROnf3SLK8d26OW91j4FrIHGbsJ8QnbEocVTOWQDA= | ||||||
|  | golang.org/x/image v0.30.0 h1:jD5RhkmVAnjqaCUXfbGBrn3lpxbknfN9w2UhHHU+5B4= | ||||||
|  | golang.org/x/image v0.30.0/go.mod h1:SAEUTxCCMWSrJcCy/4HwavEsfZZJlYxeHLc6tTiAe/c= | ||||||
|  | golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA= | ||||||
|  | golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA= | ||||||
| golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= | ||||||
|  | golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= | ||||||
|  | golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= | ||||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||||
| golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | ||||||
| golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= | ||||||
| @@ -306,6 +344,10 @@ golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= | |||||||
| golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= | golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= | ||||||
| golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= | golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= | ||||||
| golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= | golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= | ||||||
|  | golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= | ||||||
|  | golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= | ||||||
|  | golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= | ||||||
|  | golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= | ||||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||||
| golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||||
| golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= | golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= | ||||||
| @@ -326,6 +368,8 @@ golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= | |||||||
| golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | ||||||
| golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= | golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= | ||||||
| golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | ||||||
|  | golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= | ||||||
|  | golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= | ||||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
| @@ -353,6 +397,10 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= | |||||||
| golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | ||||||
| golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= | golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= | ||||||
| golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | ||||||
|  | golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= | ||||||
|  | golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | ||||||
|  | golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= | ||||||
|  | golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= | ||||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||||
| golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||||||
| golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= | golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= | ||||||
| @@ -373,6 +421,10 @@ golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= | |||||||
| golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= | golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= | ||||||
| golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg= | golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg= | ||||||
| golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0= | golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0= | ||||||
|  | golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= | ||||||
|  | golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= | ||||||
|  | golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= | ||||||
|  | golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= | ||||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||||
| @@ -395,9 +447,15 @@ golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= | |||||||
| golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= | golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= | ||||||
| golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= | golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= | ||||||
| golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= | golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= | ||||||
|  | golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= | ||||||
|  | golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= | ||||||
|  | golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= | ||||||
|  | golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= | ||||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||||
| golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= | ||||||
|  | golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= | ||||||
|  | golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= | ||||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
| google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= | ||||||
| google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= | ||||||
| @@ -415,6 +473,14 @@ google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwl | |||||||
| google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= | google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= | ||||||
| google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= | ||||||
| google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= | ||||||
|  | google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A= | ||||||
|  | google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= | ||||||
|  | google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= | ||||||
|  | google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= | ||||||
|  | google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= | ||||||
|  | google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= | ||||||
|  | google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= | ||||||
|  | google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= | ||||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| package goext | package goext | ||||||
|  |  | ||||||
| const GoextVersion = "0.0.592" | const GoextVersion = "0.0.607" | ||||||
|  |  | ||||||
| const GoextVersionTimestamp = "2025-07-16T12:46:18+0200" | const GoextVersionTimestamp = "2025-10-04T00:24:13+0200" | ||||||
|   | |||||||
| @@ -27,11 +27,11 @@ func (r GoJsonRender) Render(w http.ResponseWriter) error { | |||||||
| 	} | 	} | ||||||
| 	jsonBytes, err := MarshalSafeCollections(r.Data, r.NilSafeSlices, r.NilSafeMaps, r.Indent, r.Filter) | 	jsonBytes, err := MarshalSafeCollections(r.Data, r.NilSafeSlices, r.NilSafeMaps, r.Indent, r.Filter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		return err | ||||||
| 	} | 	} | ||||||
| 	_, err = w.Write(jsonBytes) | 	_, err = w.Write(jsonBytes) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		return err | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| @@ -39,7 +39,7 @@ func (r GoJsonRender) Render(w http.ResponseWriter) error { | |||||||
| func (r GoJsonRender) RenderString() (string, error) { | func (r GoJsonRender) RenderString() (string, error) { | ||||||
| 	jsonBytes, err := MarshalSafeCollections(r.Data, r.NilSafeSlices, r.NilSafeMaps, r.Indent, r.Filter) | 	jsonBytes, err := MarshalSafeCollections(r.Data, r.NilSafeSlices, r.NilSafeMaps, r.Indent, r.Filter) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		return "", err | ||||||
| 	} | 	} | ||||||
| 	return string(jsonBytes), nil | 	return string(jsonBytes), nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package langext | package langext | ||||||
|  |  | ||||||
|  | import "encoding/json" | ||||||
|  |  | ||||||
| type MapEntry[T comparable, V any] struct { | type MapEntry[T comparable, V any] struct { | ||||||
| 	Key   T | 	Key   T | ||||||
| 	Value V | 	Value V | ||||||
| @@ -72,6 +74,19 @@ func ForceMap[K comparable, V any](v map[K]V) map[K]V { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func ForceJsonMapOrPanic(v any) map[string]any { | ||||||
|  | 	data, err := json.Marshal(v) | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  | 	var result map[string]any | ||||||
|  | 	err = json.Unmarshal(data, &result) | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  | 	return result | ||||||
|  | } | ||||||
|  |  | ||||||
| func MapMerge[K comparable, V any](base map[K]V, arr ...map[K]V) map[K]V { | func MapMerge[K comparable, V any](base map[K]V, arr ...map[K]V) map[K]V { | ||||||
| 	res := make(map[K]V, len(base)*(1+len(arr))) | 	res := make(map[K]V, len(base)*(1+len(arr))) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,10 +2,11 @@ package rfctime | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/timeext" |  | ||||||
| 	"git.blackforestbytes.com/BlackForestBytes/goext/tst" |  | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/timeext" | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/tst" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func TestRoundtrip(t *testing.T) { | func TestRoundtrip(t *testing.T) { | ||||||
| @@ -23,8 +24,8 @@ func TestRoundtrip(t *testing.T) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if string(jstr1) != "{\"v\":\"2023-02-09T15:05:56.820915171+01:00\"}" { | 	if string(jstr1) != "{\"v\":\"2023-02-09T15:05:56.820915171+01:00\"}" { | ||||||
| 		t.Errorf(string(jstr1)) | 		t.Error(string(jstr1)) | ||||||
| 		t.Errorf("repr differs") | 		t.Error("repr differs") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	w2 := Wrap{} | 	w2 := Wrap{} | ||||||
|   | |||||||
| @@ -1,18 +1,24 @@ | |||||||
| package syncext | package syncext | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
| 	"sync" | 	"sync" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"git.blackforestbytes.com/BlackForestBytes/goext/langext" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type Atomic[T any] struct { | type Atomic[T comparable] struct { | ||||||
| 	v    T | 	v        T | ||||||
| 	lock sync.RWMutex | 	lock     sync.RWMutex | ||||||
|  | 	listener map[string]chan T | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewAtomic[T any](value T) *Atomic[T] { | func NewAtomic[T comparable](value T) *Atomic[T] { | ||||||
| 	return &Atomic[T]{ | 	return &Atomic[T]{ | ||||||
| 		v:    value, | 		v:        value, | ||||||
| 		lock: sync.RWMutex{}, | 		listener: make(map[string]chan T), | ||||||
|  | 		lock:     sync.RWMutex{}, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -26,9 +32,138 @@ func (a *Atomic[T]) Set(value T) T { | |||||||
| 	a.lock.Lock() | 	a.lock.Lock() | ||||||
| 	defer a.lock.Unlock() | 	defer a.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	return a.setInternal(value) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) setInternal(value T) T { | ||||||
|  | 	// not locked !! | ||||||
|  | 	// only call from locked context | ||||||
|  |  | ||||||
| 	oldValue := a.v | 	oldValue := a.v | ||||||
|  |  | ||||||
| 	a.v = value | 	a.v = value | ||||||
|  |  | ||||||
|  | 	for k, v := range a.listener { | ||||||
|  | 		select { | ||||||
|  | 		case v <- value: | ||||||
|  | 			// message sent | ||||||
|  | 		default: | ||||||
|  | 			// no receiver on channel | ||||||
|  | 			delete(a.listener, k) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return oldValue | 	return oldValue | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) WaitForChange() chan T { | ||||||
|  | 	outChan := make(chan T) | ||||||
|  | 	inChan := make(chan T) | ||||||
|  |  | ||||||
|  | 	uuid, _ := langext.NewHexUUID() | ||||||
|  |  | ||||||
|  | 	a.lock.Lock() | ||||||
|  | 	a.listener[uuid] = inChan | ||||||
|  | 	a.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	go func() { | ||||||
|  |  | ||||||
|  | 		v := <-inChan | ||||||
|  |  | ||||||
|  | 		a.lock.Lock() | ||||||
|  | 		delete(a.listener, uuid) | ||||||
|  | 		a.lock.Unlock() | ||||||
|  |  | ||||||
|  | 		outChan <- v | ||||||
|  |  | ||||||
|  | 		close(outChan) | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	return outChan | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) Wait(waitFor T) { | ||||||
|  | 	_ = a.WaitWithContext(context.Background(), waitFor) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) WaitWithTimeout(timeout time.Duration, waitFor T) error { | ||||||
|  | 	ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||||||
|  | 	defer cancel() | ||||||
|  | 	return a.WaitWithContext(ctx, waitFor) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) WaitWithContext(ctx context.Context, waitFor T) error { | ||||||
|  | 	if err := ctx.Err(); err != nil { | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if a.Get() == waitFor { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	uuid, _ := langext.NewHexUUID() | ||||||
|  |  | ||||||
|  | 	waitchan := make(chan T) | ||||||
|  |  | ||||||
|  | 	a.lock.Lock() | ||||||
|  | 	a.listener[uuid] = waitchan | ||||||
|  | 	a.lock.Unlock() | ||||||
|  | 	defer func() { | ||||||
|  | 		a.lock.Lock() | ||||||
|  | 		delete(a.listener, uuid) | ||||||
|  | 		a.lock.Unlock() | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	for { | ||||||
|  | 		if err := ctx.Err(); err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		timeOut := 1024 * time.Millisecond | ||||||
|  |  | ||||||
|  | 		if dl, ok := ctx.Deadline(); ok { | ||||||
|  | 			timeOutMax := dl.Sub(time.Now()) | ||||||
|  | 			if timeOutMax <= 0 { | ||||||
|  | 				timeOut = 0 | ||||||
|  | 			} else if 0 < timeOutMax && timeOutMax < timeOut { | ||||||
|  | 				timeOut = timeOutMax | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if v, ok := ReadChannelWithTimeout(waitchan, timeOut); ok { | ||||||
|  | 			if v == waitFor { | ||||||
|  | 				return nil | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			if err := ctx.Err(); err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			if a.Get() == waitFor { | ||||||
|  | 				return nil | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) Update(fn func(old T) T) { | ||||||
|  | 	a.lock.Lock() | ||||||
|  | 	defer a.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	oldValue := a.v | ||||||
|  | 	newValue := fn(oldValue) | ||||||
|  |  | ||||||
|  | 	a.setInternal(newValue) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (a *Atomic[T]) CompareAndSwap(old, new T) bool { | ||||||
|  | 	a.lock.Lock() | ||||||
|  | 	defer a.lock.Unlock() | ||||||
|  |  | ||||||
|  | 	if a.v == old { | ||||||
|  | 		a.setInternal(new) | ||||||
|  | 		return true | ||||||
|  | 	} else { | ||||||
|  | 		return false | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user