Documentation
¶
Overview ¶
Package fdv2proto defines protocol-level data types for Flag Delivery V2.
Index ¶
- Constants
- func ToStorableItems(events []Event) []ldstoretypes.Collection
- type DeleteObject
- type ErrUnknownKind
- type Error
- type Event
- type EventName
- type Goodbye
- type IntentCode
- type ObjectKind
- type Payload
- type PayloadTransferred
- type PollingPayload
- type PutObject
- type RawEvent
- type Selector
- type ServerIntent
Constants ¶
const ( // IntentTransferFull means the server intends to send a full data set. IntentTransferFull = IntentCode("xfer-full") // IntentTransferChanges means the server intends to send only the necessary changes to bring // an existing data set up-to-date. IntentTransferChanges = IntentCode("xfer-changes") // IntentNone means the server intends to send no data (payload is up to date). IntentNone = IntentCode("none") )
const ( // EventPutObject specifies that an object should be added to the data set with upsert semantics. EventPutObject = EventName("put-object") // EventDeleteObject specifies that an object should be removed from the data set. EventDeleteObject = EventName("delete-object") // EventServerIntent specifies the server's intent. EventServerIntent = EventName("server-intent") // EventPayloadTransferred specifies that that all data required to bring the existing data set to // a new version has been transferred. EventPayloadTransferred = EventName("payload-transferred") // EventHeartbeat keeps the connection alive. EventHeartbeat = EventName("heart-beat") // EventGoodbye specifies that the server is about to close the connection. EventGoodbye = EventName("goodbye") // EventError specifies that an error occurred while serving the connection. EventError = EventName("error") )
const ( // FlagKind is a flag. FlagKind = ObjectKind("flag") // SegmentKind is a segment. SegmentKind = ObjectKind("segment") )
Variables ¶
This section is empty.
Functions ¶
func ToStorableItems ¶
func ToStorableItems(events []Event) []ldstoretypes.Collection
ToStorableItems converts a list of FDv2 events to a list of collections suitable for insertion into a data store.
Types ¶
type DeleteObject ¶
type DeleteObject struct {
Version int `json:"version"`
Kind ObjectKind `json:"kind"`
Key string `json:"key"`
}
DeleteObject specifies the deletion of a particular object.
func (DeleteObject) Name ¶
func (d DeleteObject) Name() EventName
type ErrUnknownKind ¶
type ErrUnknownKind struct {
// contains filtered or unexported fields
}
ErrUnknownKind represents that a given ObjectKind had no FDv1 equivalent DataKind.
func (*ErrUnknownKind) Error ¶
func (e *ErrUnknownKind) Error() string
func (*ErrUnknownKind) Is ¶
func (e *ErrUnknownKind) Is(err error) bool
Is returns true if the error is an ErrUnknownKind.
type Event ¶
type Event interface {
// Name returns the name of the event.
Name() EventName
}
Event represents an event that can be sent by the server.
type Goodbye ¶
type Goodbye struct {
Reason string `json:"reason"`
Silent bool `json:"silent"`
Catastrophe bool `json:"catastrophe"`
}
Goodbye represents a goodbye event.
type IntentCode ¶
type IntentCode string
IntentCode represents the various intents that can be sent by the server.
type ObjectKind ¶
type ObjectKind string
ObjectKind represents the kind of object.
func (ObjectKind) ToFDV1 ¶
func (o ObjectKind) ToFDV1() (datakinds.DataKindInternal, error)
ToFDV1 converts the object kind to an FDv1 data kind. If there is no equivalent, it returns an ErrUnknownKind.
type Payload ¶
type Payload struct {
// It would be nice if we had the same value available in both so we could
// use that as the key consistently throughout the the process.
ID string `json:"id"`
Target int `json:"target"`
Code IntentCode `json:"code"`
Reason string `json:"reason"`
}
Payload represents a payload delivered in a streaming response.
type PayloadTransferred ¶
PayloadTransferred represents the fact that all payload objects have been sent.
func (PayloadTransferred) Name ¶
func (p PayloadTransferred) Name() EventName
type PollingPayload ¶
type PollingPayload struct {
// Note: the first event in a PollingPayload should be a Payload.
Events []RawEvent `json:"events"`
}
PollingPayload represents a payload that is delivered in a polling response.
type PutObject ¶
type PutObject struct {
Version int `json:"version"`
Kind ObjectKind `json:"kind"`
Key string `json:"key"`
Object any `json:"object"`
}
PutObject specifies the addition of a particular object with upsert semantics.
type RawEvent ¶
type RawEvent struct {
Name EventName `json:"name"`
Data json.RawMessage `json:"data"`
}
RawEvent is a partially deserialized event that allows the the event name to be extracted before the rest of the event is deserialized.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector represents a particular snapshot of data.
func NewSelector ¶
NewSelector creates a new Selector from a state string and version.
func NoSelector ¶
func NoSelector() *Selector
NoSelector returns a nil Selector, representing the lack of one. It is here only for readability at call sites.
func (*Selector) State ¶
State returns the state string of the Selector. This cannot be called if the Selector is nil.
func (*Selector) UnmarshalJSON ¶
UnmarshalJSON unmarshals a Selector from JSON.
type ServerIntent ¶
type ServerIntent struct {
// Payloads is a list of payloads, defined to be at least length 1.
Payloads []Payload `json:"payloads"`
}
ServerIntent represents the server's intent.
func (ServerIntent) Name ¶
func (ServerIntent) Name() EventName