feat: implement cross-node event broadcasting with NATSEventBus
All checks were successful
CI / build (pull_request) Successful in 1m28s
All checks were successful
CI / build (pull_request) Successful in 1m28s
- Add UpdateVersionCache method to JetStreamEventStore for cache synchronization - Add SubscribeToEventStored convenience helper to NATSEventBus - Create integration tests for cross-node broadcasting scenarios - Add example demonstrating NATSEventBus + JetStreamEventStore integration
This commit is contained in:
36
store/helpers_test.go
Normal file
36
store/helpers_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// getTestNATSConnection returns a NATS connection for testing.
|
||||
// This helper is used by benchmark tests that require NATS.
|
||||
func getTestNATSConnection(t *testing.T) *nats.Conn {
|
||||
nc, err := nats.Connect(nats.DefaultURL)
|
||||
if err != nil {
|
||||
t.Skipf("NATS not available: %v", err)
|
||||
}
|
||||
return nc
|
||||
}
|
||||
|
||||
// getVersionFromEvent extracts version from EventStored event data.
|
||||
func getVersionFromEvent(data map[string]interface{}) int64 {
|
||||
switch v := data["version"].(type) {
|
||||
case float64:
|
||||
return int64(v)
|
||||
case int64:
|
||||
return v
|
||||
case int:
|
||||
return int64(v)
|
||||
case uint64:
|
||||
return int64(v)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user