Documentation
¶
Overview ¶
Package wireconv provides total, composable conversions between the frozen warden domain types (services/warden) and the generated candacenet.warden.v1 protobuf messages (services/warden/proto/warden/v1). It is the single boundary the gRPC plane (server, client, and protojson persistence) crosses to move between the in-memory domain model and the wire representation.
Every conversion is:
- Total: a nil or zero input yields a well-defined output; no converter panics and none returns an error (structural validity is guaranteed by the generated types, semantic validation lives at the RPC boundary).
- Lossless: for a fully-populated value the round trip domain -> proto -> domain (and proto -> domain -> proto) reproduces the input exactly. This is property-tested in wireconv_contract_test.go over full-population fixtures INCLUDING Membership.CreatedInTerm — the field a past Clone regression silently zeroed.
Nil discipline. The proto model uses pointers where the domain uses either a value (ClusterView.Membership, PeerView) or an optional pointer (HeartbeatRequest.View/Membership, PersistentState.Membership). Value-to-proto converters therefore always return a non-nil message; the *Ptr* variants preserve nil to model "field absent" on the wire.
Index ¶
- func ClusterViewFromProto(p *wardenv1.ClusterView) warden.ClusterView
- func ClusterViewPtrFromProto(p *wardenv1.ClusterView) *warden.ClusterView
- func ClusterViewPtrToProto(v *warden.ClusterView) *wardenv1.ClusterView
- func ClusterViewToProto(v warden.ClusterView) *wardenv1.ClusterView
- func CursorEqual(a, b *wardenv1.ClusterViewCursor) bool
- func CursorOf(v *wardenv1.ClusterView) *wardenv1.ClusterViewCursor
- func HeartbeatRequestFromProto(p *wardenv1.HeartbeatRequest) warden.HeartbeatRequest
- func HeartbeatRequestToProto(r warden.HeartbeatRequest) *wardenv1.HeartbeatRequest
- func HeartbeatResponseFromProto(p *wardenv1.HeartbeatResponse) warden.HeartbeatResponse
- func HeartbeatResponseToProto(r warden.HeartbeatResponse) *wardenv1.HeartbeatResponse
- func IdentifyResponseFromProto(p *wardenv1.IdentifyResponse) warden.IdentifyResponse
- func IdentifyResponseToProto(r warden.IdentifyResponse) *wardenv1.IdentifyResponse
- func MembershipFromProto(p *wardenv1.Membership) warden.Membership
- func MembershipPtrFromProto(p *wardenv1.Membership) *warden.Membership
- func MembershipPtrToProto(m *warden.Membership) *wardenv1.Membership
- func MembershipToProto(m warden.Membership) *wardenv1.Membership
- func NodeFromProto(p *wardenv1.Node) warden.Node
- func NodeToProto(n warden.Node) *wardenv1.Node
- func PeerViewFromProto(p *wardenv1.PeerView) warden.PeerView
- func PeerViewToProto(pv warden.PeerView) *wardenv1.PeerView
- func PersistentStateFromProto(p *wardenv1.PersistentState) warden.PersistentState
- func PersistentStateToProto(st warden.PersistentState) *wardenv1.PersistentState
- func VoteRequestFromProto(p *wardenv1.VoteRequest) warden.VoteRequest
- func VoteRequestToProto(r warden.VoteRequest) *wardenv1.VoteRequest
- func VoteResponseFromProto(p *wardenv1.VoteResponse) warden.VoteResponse
- func VoteResponseToProto(r warden.VoteResponse) *wardenv1.VoteResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClusterViewFromProto ¶
func ClusterViewFromProto(p *wardenv1.ClusterView) warden.ClusterView
ClusterViewFromProto converts a proto ClusterView; a nil message is the zero value.
func ClusterViewPtrFromProto ¶
func ClusterViewPtrFromProto(p *wardenv1.ClusterView) *warden.ClusterView
ClusterViewPtrFromProto preserves nil, inverting ClusterViewPtrToProto.
func ClusterViewPtrToProto ¶
func ClusterViewPtrToProto(v *warden.ClusterView) *wardenv1.ClusterView
ClusterViewPtrToProto preserves nil (HeartbeatRequest.View is optional).
func ClusterViewToProto ¶
func ClusterViewToProto(v warden.ClusterView) *wardenv1.ClusterView
ClusterViewToProto converts a domain ClusterView value (always non-nil).
func CursorEqual ¶
func CursorEqual(a, b *wardenv1.ClusterViewCursor) bool
CursorEqual reports whether two cursors denote the same observable state. A nil cursor is treated as the zero cursor, so a client that opens a watch without a `since` cursor never accidentally matches a populated one.
func CursorOf ¶
func CursorOf(v *wardenv1.ClusterView) *wardenv1.ClusterViewCursor
CursorOf derives the dedup/resume cursor from a proto ClusterView: the (membership.version, membership.created_in_term, view.updated_at) triple the schema fixes as the identity of an observable cluster state. It is always non-nil; a nil view yields the zero cursor.
func HeartbeatRequestFromProto ¶
func HeartbeatRequestFromProto(p *wardenv1.HeartbeatRequest) warden.HeartbeatRequest
HeartbeatRequestFromProto converts a proto HeartbeatRequest; a nil message is the zero request.
func HeartbeatRequestToProto ¶
func HeartbeatRequestToProto(r warden.HeartbeatRequest) *wardenv1.HeartbeatRequest
HeartbeatRequestToProto converts a domain HeartbeatRequest (always non-nil); its optional View and Membership preserve nil.
func HeartbeatResponseFromProto ¶
func HeartbeatResponseFromProto(p *wardenv1.HeartbeatResponse) warden.HeartbeatResponse
HeartbeatResponseFromProto converts a proto HeartbeatResponse; a nil message is the zero response.
func HeartbeatResponseToProto ¶
func HeartbeatResponseToProto(r warden.HeartbeatResponse) *wardenv1.HeartbeatResponse
HeartbeatResponseToProto converts a domain HeartbeatResponse (always non-nil).
func IdentifyResponseFromProto ¶
func IdentifyResponseFromProto(p *wardenv1.IdentifyResponse) warden.IdentifyResponse
IdentifyResponseFromProto converts a proto IdentifyResponse; a nil message is the zero response.
func IdentifyResponseToProto ¶
func IdentifyResponseToProto(r warden.IdentifyResponse) *wardenv1.IdentifyResponse
IdentifyResponseToProto converts a domain IdentifyResponse (always non-nil).
func MembershipFromProto ¶
func MembershipFromProto(p *wardenv1.Membership) warden.Membership
MembershipFromProto converts a proto Membership to the domain value; a nil message is the zero Membership.
func MembershipPtrFromProto ¶
func MembershipPtrFromProto(p *wardenv1.Membership) *warden.Membership
MembershipPtrFromProto preserves nil, inverting MembershipPtrToProto.
func MembershipPtrToProto ¶
func MembershipPtrToProto(m *warden.Membership) *wardenv1.Membership
MembershipPtrToProto preserves nil (the "no membership conveyed" signal used by HeartbeatRequest and PersistentState).
func MembershipToProto ¶
func MembershipToProto(m warden.Membership) *wardenv1.Membership
MembershipToProto converts a domain Membership value to a non-nil proto message. Use MembershipPtrToProto where nil must survive as "no change".
func NodeFromProto ¶
NodeFromProto converts a proto Node to the domain type; a nil message is the zero Node.
func NodeToProto ¶
NodeToProto converts a domain Node to its proto message (always non-nil).
func PeerViewFromProto ¶
PeerViewFromProto converts a proto PeerView; a nil message is the zero value.
func PeerViewToProto ¶
PeerViewToProto converts a domain PeerView (always non-nil). Member is copied verbatim: an empty MemberKind stays empty (the proto reader treats empty as the voter default, matching the JSON omitempty contract) so the round trip is exact rather than normalising.
func PersistentStateFromProto ¶
func PersistentStateFromProto(p *wardenv1.PersistentState) warden.PersistentState
PersistentStateFromProto converts a proto PersistentState; a nil message is the zero state.
func PersistentStateToProto ¶
func PersistentStateToProto(st warden.PersistentState) *wardenv1.PersistentState
PersistentStateToProto converts the durable election record (always non-nil).
func VoteRequestFromProto ¶
func VoteRequestFromProto(p *wardenv1.VoteRequest) warden.VoteRequest
VoteRequestFromProto converts a proto VoteRequest; a nil message is the zero request.
func VoteRequestToProto ¶
func VoteRequestToProto(r warden.VoteRequest) *wardenv1.VoteRequest
VoteRequestToProto converts a domain VoteRequest (always non-nil).
func VoteResponseFromProto ¶
func VoteResponseFromProto(p *wardenv1.VoteResponse) warden.VoteResponse
VoteResponseFromProto converts a proto VoteResponse; a nil message is the zero response.
func VoteResponseToProto ¶
func VoteResponseToProto(r warden.VoteResponse) *wardenv1.VoteResponse
VoteResponseToProto converts a domain VoteResponse (always non-nil).
Types ¶
This section is empty.