From aa3d40f82cd32fd321e78bd7c80124ee9e685465 Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Tue, 31 Oct 2023 10:34:09 +0000 Subject: [PATCH] Added JMESpath to query the state of specific meshes. --- pkg/automerge/types.go | 14 +++++++------- pkg/lib/conv.go | 12 ++++++++++++ pkg/sync/syncservice.go | 2 ++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pkg/automerge/types.go b/pkg/automerge/types.go index 7f399e6..81b10f4 100644 --- a/pkg/automerge/types.go +++ b/pkg/automerge/types.go @@ -2,15 +2,15 @@ package crdt // MeshNodeCrdt: Represents a CRDT for a mesh nodes type MeshNodeCrdt struct { - HostEndpoint string `automerge:"hostEndpoint" json:"hostEndpoint"` - WgEndpoint string `automerge:"wgEndpoint" json:"wgEndpoint"` - PublicKey string `automerge:"publicKey" json:"publicKey"` - WgHost string `automerge:"wgHost" json:"wgHost"` - Timestamp int64 `automerge:"timestamp" json:"timestamp"` - Routes map[string]interface{} `automerge:"routes" json:"routes"` + HostEndpoint string `automerge:"hostEndpoint"` + WgEndpoint string `automerge:"wgEndpoint"` + PublicKey string `automerge:"publicKey"` + WgHost string `automerge:"wgHost"` + Timestamp int64 `automerge:"timestamp"` + Routes map[string]interface{} `automerge:"routes"` } // MeshCrdt: Represents the mesh network as a whole type MeshCrdt struct { - Nodes map[string]MeshNodeCrdt `automerge:"nodes" json:"nodes"` + Nodes map[string]MeshNodeCrdt `automerge:"nodes"` } diff --git a/pkg/lib/conv.go b/pkg/lib/conv.go index 1f115aa..0536ae4 100644 --- a/pkg/lib/conv.go +++ b/pkg/lib/conv.go @@ -43,3 +43,15 @@ func MapKeys[K comparable, V any](m map[K]V) []K { return values } + +type convert[V1 any, V2 any] func(V1) V2 + +func Map[V1 any, V2 any](list []V1, f convert[V1, V2]) []V2 { + newList := make([]V2, len(list)) + + for i, elem := range list { + newList[i] = f(elem) + } + + return newList +} diff --git a/pkg/sync/syncservice.go b/pkg/sync/syncservice.go index f2e9b67..7ebc1d8 100644 --- a/pkg/sync/syncservice.go +++ b/pkg/sync/syncservice.go @@ -87,10 +87,12 @@ func (s *SyncServiceImpl) SyncMesh(stream rpc.SyncService_SyncMeshServer) error if syncer != nil { syncer.Complete() } + return nil } } } + func NewSyncService(server *ctrlserver.MeshCtrlServer) *SyncServiceImpl { return &SyncServiceImpl{Server: server} }