Commit 0991b54
authored
Refactor server architecture with multi-backend support and LibP2P in… (#154)
Refactor server architecture with multi-backend support, LibP2P integration, and resource reconciliation
Major architectural changes:
- Backend abstraction layer supporting HTTP, gRPC, CoAP, and LibP2P transports
- Client refactoring with automatic backend fallback and selection
- Server handler registry pattern for better modularity
- LibP2P P2P networking with relay, DHT, and NAT traversal
- Kubernetes-style resource reconciliation with drift detection
- Subscription improvements with defensive nil checking
Resource reconciliation system:
- Resource and ResourceDefinition types for declarative infrastructure
- Automatic drift detection and correction mechanism
- JSON Schema-based resource validation
- Namespaced resource management with metadata (labels, annotations)
- Resource status tracking with generation counters
- Reconciliation actions: create, update, delete, noop
- Field-level change tracking for spec, status, and metadata
- Handler specification for executor-based reconciliation
Backend improvements:
- Unified backend interface for HTTP (Gin), gRPC, CoAP, and LibP2P
- Multi-backend client with automatic failover
- DHT-based peer discovery for LibP2P
- Circuit relay v2 for NAT traversal
- Server manager for coordinating multiple backend servers
Client enhancements:
- Modular client architecture with per-domain clients
- Automatic backend selection and fallback
- LibP2P client with DHT caching
- Support for HTTP, gRPC, CoAP, and LibP2P transports
Server refactoring:
- Handler registry pattern for better organization
- Moved handlers to domain-specific packages
- Resource handler for managing ResourceDefinitions and Resources
- Improved controller architecture
- Better test isolation and mocking
Database layer:
- ResourceDatabase interface with PostgreSQL implementation
- Resource and ResourceDefinition CRUD operations
- Namespace and kind-based queries
- JSON/JSONB column support for flexible schemas
- Database migration support for resource tables
LibP2P/P2P features:
- P2P relay server with CLI integration (colonies p2p relay)
- Identity generation (colonies p2p generate)
- DHT peer discovery with caching
- AutoNAT and hole punching support
- Bootstrap peer management
Resource management features:
- Declarative resource specifications with desired state
- Custom Resource Definition (CRD) support
- Schema validation with required fields, types, and enums
- Nested object and array validation
- Helper methods for GetAPIVersion, Diff, ValidateAgainstRD
- Resource arrays and JSON conversion utilities
Bug fixes:
- Fixed nil pointer panics in subscription cleanup (Gin and LibP2P)
- Fixed DHT cache to only store active peers
- Fixed database test isolation with unique table prefixes
- Fixed TestSearchLogs timing boundary issue with PostgreSQL NOW()
- Removed APIVersion field from Resource struct (moved to ResourceDefinition)
- Updated hardcoded peer IDs to current server identity
Testing improvements:
- Fixed controller test database conflicts
- Added DatabaseMock resource interface methods
- Improved test utilities and mocking
- Better test isolation with unique database prefixes
- Added comprehensive backend tests
- Added resource validation test coverage
- Added reconciliation and diff testing
Core domain improvements:
- Resource type with Kind, Metadata, Spec, Status fields
- ResourceDefinition with Group, Version, Names, Scope, Handler
- ValidationSchema for JSON Schema validation
- Reconciliation type for tracking old/new state with diffs
- ResourceDiff with field-level change tracking
- FunctionSpec integration for reconciliation workflows
CLI enhancements:
- New 'colonies p2p' subcommand for relay and identity management
- Improved server startup with backend selection
- Better configuration management
Documentation:
- Added Container Building Guide with multi-platform instructions
- Docker buildx setup and QEMU configuration
- Multi-architecture build examples (amd64, arm64)
- CI/CD integration examples for GitHub Actions and GitLab
- Troubleshooting guide for buildx issues1 parent 9e057f6 commit 0991b54
3,565 files changed
Lines changed: 394149 additions & 182776 deletions
File tree
- .github/workflows
- buildtools
- docs
- examples/resources
- internal/cli
- pkg
- backends
- coap
- gin
- grpc
- libp2p
- client
- backends
- coap
- gin
- grpc
- proto
- libp2p
- constants
- core
- database
- postgresql
- fs
- rpc
- server
- controllers
- handlers
- attribute
- colony
- cron
- executor
- file
- function
- generator
- log
- processgraph
- process
- realtime
- resource
- security
- server
- snapshot
- user
- registry
- utils
- tests/other
- vendor
- github.com
- cenkalti/backoff
- v4
- v5
- cespare/xxhash/v2
- containerd/cgroups
- stats/v1
- coreos/go-systemd/v22/dbus
- decred/dcrd/dcrec/secp256k1/v4
- ecdsa
- docker/go-units
- dsnet/golib/memfile
- elastic/gosigar
- sys/windows
- filecoin-project/go-clock
- gabriel-vasile/mimetype
- internal
- charset
- csv
- json
- magic
- markup
- scan
- go-logr/logr
- funcr
- go-task/slim-sprig
- godbus/dbus/v5
- golang/protobuf
- jsonpb
- protoc-gen-go/descriptor
- ptypes
- google/pprof
- profile
- gorilla/websocket
- grpc-ecosystem/grpc-gateway/v2
- runtime
- utilities
- hashicorp
- errwrap
- go-multierror
- golang-lru/v2
- internal
- simplelru
- ipfs
- boxo
- ipns
- pb
- util
- go-cid
- go-datastore
- autobatch
- query
- sync
- go-log
- tracer
- wire
- v2
- writer
- jbenet/goprocess
- klauspost
- compress
- fse
- huff0
- internal
- le
- snapref
- s2
- zstd
- internal/xxhash
- cpuid/v2
- koron/go-ssdp
- internal
- multicast
- ssdplog
- libp2p
- go-flow-metrics
- go-libp2p-core
- crypto
- peer
- record
- go-libp2p-kad-dht
- amino
- internal
- config
- metrics
- net
- metrics
- netsize
- pb
- records
- rtrefresh
- go-libp2p-kbucket
- keyspace
- peerdiversity
- go-libp2p-pubsub
- pb
- timecache
- go-libp2p-record
- pb
- go-libp2p
- config
- core
- connmgr
- crypto
- pb
- discovery
- event
- host
- network
- peerstore
- peer
- pb
- record
- pb
- routing
- sec/insecure
- pb
- transport
- internal/sha256
- p2p
- discovery
- backoff
- routing
- util
- host
- autonat
- pb
- autorelay
- basic
- internal/backoff
- blank
- eventbus
- peerstore/pstoremem
- pstoremanager
- resource-manager
- routed
- metricshelper
- muxer/yamux
- net
- connmgr
- nat
- internal/nat
- pnet
- reuseport
- swarm
- upgrader
- protocol
- autonatv2
- pb
- circuitv2
- client
- pb
- relay
- holepunch
- pb
- identify
- internal/user-agent
- pb
- ping
- security
- noise
- pb
- tls
- transport
- quicreuse
- quic
- tcpreuse
- internal/sampledconn
- tcp
- webrtc
- pb
- udpmux
- websocket
- webtransport
- x/rate
- go-nat
- go-netroute
- go-yamux
- v4
- v5
- miekg/dns
- multiformats
- go-multiaddr-dns
- go-multiaddr
- net
- x/meg
- go-multicodec
- go-multistream
- go-varint
- munnerz/goautoneg
- onsi/ginkgo/v2
- config
- formatter
- ginkgo
- build
- command
- generators
- internal
- labels
- outline
- run
- unfocus
- watch
- internal
- interrupt_handler
- parallel_support
- reporters
- types
- opencontainers/runtime-spec
- specs-go
- opentracing/opentracing-go
- ext
- log
- pion
- datachannel
- dtls
- v2
- internal
- ciphersuite
- types
- closer
- util
- pkg
- crypto
- ccm
- ciphersuite
- clientcertificate
- elliptic
- hash
- prf
- signaturehash
- signature
- protocol
- alert
- extension
- handshake
- recordlayer
- v3
- internal
- ciphersuite
- types
- closer
- net
- udp
- util
- pkg
- crypto
- ccm
- ciphersuite
- clientcertificate
- elliptic
- fingerprint
- hash
- prf
- signaturehash
- signature
- net
- protocol
- alert
- extension
- handshake
- recordlayer
- ice/v4
- internal
- atomic
- fakenet
- stun
- taskloop
- interceptor
- internal
- ntp
- rtpbuffer
- sequencenumber
- pkg
- flexfec
- util
- nack
- report
- rfc8888
- twcc
- logging
- mdns/v2
- randutil
- rtcp
- rtp
- codecs
- av1/obu
- vp9
- sctp
- sdp/v3
- srtp/v3
- stun
- internal/hmac
- v3
- internal/hmac
- transport
- v2
- connctx
- deadline
- packetio
- replaydetector
- stdnet
- udp
- utils/xor
- v3
- deadline
- netctx
- packetio
- replaydetector
- stdnet
- utils/xor
- vnet
- turn/v4
- internal
- allocation
- client
- ipnet
- proto
- server
- webrtc/v4
- internal
- fmtp
- mux
- util
- pkg
- media
- rtcerr
- plgd-dev/go-coap/v3
- dtls/server
- message
- codes
- noresponse
- pool
- mux
- net
- blockwise
- client
- limitParallelRequests
- monitor/inactivity
- observation
- responsewriter
- options
- config
- pkg
- cache
- connections
- errors
- fn
- math
- rand
- runner/periodic
- sync
- tcp
- client
- coder
- server
- udp
- client
- coder
- server
- prometheus
- client_golang
- internal/github.com/golang/gddo
- httputil
- header
- prometheus
- internal
- promhttp
- internal
- client_model/go
- common
- expfmt
- internal/bitbucket.org/ww/goautoneg
- model
- procfs
- internal
- fs
- util
- quic-go
- qpack
- quic-go
- http3
- internal
- ackhandler
- congestion
- flowcontrol
- handshake
- logutils
- protocol
- qerr
- qtls
- utils
- wire
- logging
- metrics
- qlog
- quicvarint
- webtransport-go
- raulk/go-watchdog
- stretchr/testify/assert
- yaml
- wlynxg/anet
- go.opencensus.io
- internal/tagencoding
- metric
- metricdata
- metricproducer
- resource
- stats
- internal
- view
- tag
- go.opentelemetry.io
- auto/sdk
- internal/telemetry
- otel
- attribute
- internal
- baggage
- codes
- exporters/otlp/otlptrace
- internal/tracetransform
- otlptracegrpc
- internal
- envconfig
- otlpconfig
- retry
- internal
- attribute
- baggage
- global
- metric
- embedded
- noop
- propagation
- sdk
- instrumentation
- internal
- env
- x
- resource
- trace
- internal/x
- semconv
- internal
- v1.17.0
- v1.24.0
- v1.37.0
- otelconv
- v1.4.0
- trace
- embedded
- internal/telemetry
- noop
- proto/otlp
- collector/trace/v1
- common/v1
- resource/v1
- trace/v1
- go.uber.org
- atomic
- dig
- internal/digclock
- fx
- fxevent
- internal
- fxclock
- lifecycle
- mock/mockgen
- zap
- buffer
- zapcore
- zapgrpc
- go.yaml.in/yaml/v2
- golang.org/x
- crypto
- argon2
- bcrypt
- blake2b
- blake2s
- blowfish
- chacha20poly1305
- chacha20
- cryptobyte
- asn1
- curve25519
- internal/field
- hkdf
- internal/poly1305
- salsa20/salsa
- sha3
- exp
- constraints
- maps
- rand
- slices
- mod
- modfile
- module
- semver
- net
- context
- dns/dnsmessage
- html
- atom
- http2
- h2c
- http/httpguts
- internal
- httpcommon
- socket
- proxy
- publicsuffix
- data
- route
- trace
- sync
- errgroup
- semaphore
- sys
- cpu
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
2 | 27 | | |
3 | 28 | | |
4 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
5 | 32 | | |
6 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
21 | 30 | | |
22 | 31 | | |
23 | | - | |
| 32 | + | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
| |||
32 | 41 | | |
33 | 42 | | |
34 | 43 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 44 | | |
53 | 45 | | |
54 | 46 | | |
| |||
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
60 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
| |||
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments