Documentation
¶
Overview ¶
Package ldservicesv2 provides test helpers for generating fdv2 protocol data.
Index ¶
- type ProtocolEvents
- type ServerSDKData
- func (s *ServerSDKData) Flags(flags ...ldmodel.FeatureFlag) *ServerSDKData
- func (s *ServerSDKData) Segments(segments ...ldmodel.Segment) *ServerSDKData
- func (s *ServerSDKData) String() string
- func (s *ServerSDKData) ToInitializerPayload(selector subsystems.Selector) subsystems.PollingPayload
- func (s *ServerSDKData) ToPutObjects() []subsystems.PutObject
- type StreamingProtocol
- func (f *StreamingProtocol) Enqueue(control httphelpers.SSEStreamControl)
- func (f *StreamingProtocol) HasNext() bool
- func (f *StreamingProtocol) Next() httphelpers.SSEEvent
- func (f *StreamingProtocol) SSEEvents() []eventsource.Event
- func (f *StreamingProtocol) WithDeleteObject(object subsystems.DeleteObject) *StreamingProtocol
- func (f *StreamingProtocol) WithError(err subsystems.Error) *StreamingProtocol
- func (f *StreamingProtocol) WithGoodbye(goodbye subsystems.Goodbye) *StreamingProtocol
- func (f *StreamingProtocol) WithIntent(intent subsystems.ServerIntent) *StreamingProtocol
- func (f *StreamingProtocol) WithPutObject(object subsystems.PutObject) *StreamingProtocol
- func (f *StreamingProtocol) WithPutObjects(objects []subsystems.PutObject) *StreamingProtocol
- func (f *StreamingProtocol) WithTransferred(state string, version int) *StreamingProtocol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProtocolEvents ¶
type ProtocolEvents []httphelpers.SSEEvent
ProtocolEvents represents a list of SSE-formatted events.
func (ProtocolEvents) Enqueue ¶
func (p ProtocolEvents) Enqueue(control httphelpers.SSEStreamControl)
Enqueue adds all the events to an SSEStreamController.
type ServerSDKData ¶
type ServerSDKData struct {
FlagsMap map[string]ldmodel.FeatureFlag `json:"flags"`
SegmentsMap map[string]ldmodel.Segment `json:"segments"`
}
ServerSDKData is a convenience type for constructing a test server-side SDK data payload for PollingServiceHandler or StreamingServiceHandler. Its String() method returns a JSON object with the expected "flags" and "segments" properties.
data := NewServerSDKData().Flags(flag1, flag2) handler := PollingServiceHandler(data)
func NewServerSDKData ¶
func NewServerSDKData() *ServerSDKData
NewServerSDKData creates a ServerSDKData instance.
func (*ServerSDKData) Flags ¶
func (s *ServerSDKData) Flags(flags ...ldmodel.FeatureFlag) *ServerSDKData
Flags adds the specified items to the struct's "flags" map.
Each item may be either a object produced by KeyAndVersionItem or a real data model object from the ldmodel package. The minimum requirement is that when converted to JSON, it has a "key" property.
func (*ServerSDKData) Segments ¶
func (s *ServerSDKData) Segments(segments ...ldmodel.Segment) *ServerSDKData
Segments adds the specified items to the struct's "segments" map.
Each item may be either a object produced by KeyAndVersionItem or a real data model object from the ldmodel package. The minimum requirement is that when converted to JSON, it has a "key" property.
func (*ServerSDKData) String ¶
func (s *ServerSDKData) String() string
String returns the JSON encoding of the struct as a string.
func (*ServerSDKData) ToInitializerPayload ¶ added in v7.9.0
func (s *ServerSDKData) ToInitializerPayload(selector subsystems.Selector) subsystems.PollingPayload
ToInitializerPayload converts the data to a PollingPayload object that can be fed to a mock polling service.
func (*ServerSDKData) ToPutObjects ¶
func (s *ServerSDKData) ToPutObjects() []subsystems.PutObject
ToPutObjects converts the data to a list of PutObject objects that can be fed to a mock streaming data source.
type StreamingProtocol ¶
type StreamingProtocol struct {
// contains filtered or unexported fields
}
StreamingProtocol is a builder for creating a sequence of events that can be sent as an SSE stream.
func NewStreamingProtocol ¶
func NewStreamingProtocol() *StreamingProtocol
NewStreamingProtocol creates a new StreamingProtocol instance.
func (*StreamingProtocol) Enqueue ¶
func (f *StreamingProtocol) Enqueue(control httphelpers.SSEStreamControl)
Enqueue adds all the events to an SSEStreamController.
func (*StreamingProtocol) HasNext ¶
func (f *StreamingProtocol) HasNext() bool
HasNext returns true if there are more events in the protocol.
func (*StreamingProtocol) Next ¶
func (f *StreamingProtocol) Next() httphelpers.SSEEvent
Next returns the next event in the protocol, popping the event from protocol's internal queue.
func (*StreamingProtocol) SSEEvents ¶ added in v7.10.2
func (f *StreamingProtocol) SSEEvents() []eventsource.Event
SSEEvents returns the events in the protocol and clears the internal queue.
func (*StreamingProtocol) WithDeleteObject ¶ added in v7.10.2
func (f *StreamingProtocol) WithDeleteObject(object subsystems.DeleteObject) *StreamingProtocol
WithDeleteObject adds a DeleteObject event to the protocol.
func (*StreamingProtocol) WithError ¶ added in v7.11.0
func (f *StreamingProtocol) WithError(err subsystems.Error) *StreamingProtocol
WithError adds an Error event to the protocol.
func (*StreamingProtocol) WithGoodbye ¶ added in v7.11.0
func (f *StreamingProtocol) WithGoodbye(goodbye subsystems.Goodbye) *StreamingProtocol
WithGoodbye adds a Goodbye event to the protocol.
func (*StreamingProtocol) WithIntent ¶
func (f *StreamingProtocol) WithIntent(intent subsystems.ServerIntent) *StreamingProtocol
WithIntent adds a ServerIntent event to the protocol.
func (*StreamingProtocol) WithPutObject ¶
func (f *StreamingProtocol) WithPutObject(object subsystems.PutObject) *StreamingProtocol
WithPutObject adds a PutObject event to the protocol.
func (*StreamingProtocol) WithPutObjects ¶
func (f *StreamingProtocol) WithPutObjects(objects []subsystems.PutObject) *StreamingProtocol
WithPutObjects adds multiple PutObject events to the protocol.
func (*StreamingProtocol) WithTransferred ¶
func (f *StreamingProtocol) WithTransferred(state string, version int) *StreamingProtocol
WithTransferred adds a PayloadTransferred event to the protocol with a given version. The state is an arbitrary placeholder string; if tests are added that need to verify properties related to the state, this can be updated.