-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstream.go
More file actions
77 lines (69 loc) · 1.96 KB
/
Copy pathstream.go
File metadata and controls
77 lines (69 loc) · 1.96 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package caido
import (
"context"
gen "github.com/caido-community/sdk-go/graphql"
)
// StreamSDK provides read access to WebSocket and SSE streams (the Streams
// tab in Caido) and their frames.
type StreamSDK struct {
client *Client
}
// ListStreamsOptions configures the List query.
//
// Caido 0.57.0 removed the protocol argument from the streams query and
// replaced it with an optional StreamQL filter. To restrict results to a
// protocol, set Filter to a StreamQL query (e.g. `protocol.eq:"ws"`) or
// filter the returned streams by their Protocol field.
type ListStreamsOptions struct {
First *int
Last *int
After *string
Before *string
Filter *gen.StreamQLInput
Order *gen.StreamOrderInput
ScopeID *string
}
// List returns paginated streams (connections), optionally filtered by a
// StreamQL query.
func (s *StreamSDK) List(
ctx context.Context, opts *ListStreamsOptions,
) (*gen.ListStreamsResponse, error) {
var o ListStreamsOptions
if opts != nil {
o = *opts
}
return gen.ListStreams(
ctx, s.client.GraphQL,
o.First, o.Last, o.After, o.Before,
o.Filter, o.Order, o.ScopeID,
)
}
// Get returns a single stream by ID.
func (s *StreamSDK) Get(
ctx context.Context, id string,
) (*gen.GetStreamResponse, error) {
return gen.GetStream(ctx, s.client.GraphQL, id)
}
// ListWsMessagesOptions configures the WebSocket frame query.
type ListWsMessagesOptions struct {
First *int
Last *int
After *string
Before *string
Order *gen.StreamWsMessageOrderInput
}
// ListWsMessages returns paginated WebSocket frames for a stream. Frame
// content (direction, format, length, raw Blob) lives on each message's
// head field.
func (s *StreamSDK) ListWsMessages(
ctx context.Context, streamID string, opts *ListWsMessagesOptions,
) (*gen.ListStreamWsMessagesResponse, error) {
var o ListWsMessagesOptions
if opts != nil {
o = *opts
}
return gen.ListStreamWsMessages(
ctx, s.client.GraphQL,
streamID, o.First, o.Last, o.After, o.Before, o.Order,
)
}