You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: go/gosdk/gosdk.go
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ type HttpFilterConfig interface {
27
27
// This is passed to each event hook of the HttpFilter.
28
28
//
29
29
// **WARNING**: This must not outlive each event hook since there's no guarantee that the EnvoyHttpFilter will be valid after the event hook is returned.
30
+
// To perform the asynchronous operations, use [EnvoyHttpFilter.NewScheduler] to create a [Scheduler] and perform the operations in a separate Goroutine.
31
+
// Then, use the [Scheduler.Commit] method to commit the event to the Envoy filter on the correct worker thread to continue processing the request.
30
32
typeEnvoyHttpFilterinterface {
31
33
// GetRequestHeader gets the first value of the request header. Returns the value and true if the header is found.
32
34
GetRequestHeader(keystring) (string, bool)
@@ -59,6 +61,26 @@ type EnvoyHttpFilter interface {
59
61
GetSourceAddress() string
60
62
// GetRequestProtocol gets the request protocol. This corresponds to `request.protocol` attribute https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes.
61
63
GetRequestProtocol() string
64
+
// NewScheduler creates a new Scheduler that can be used to schedule events to the correct Envoy worker thread.
65
+
// Created schedulers must be closed when they are no longer needed.
66
+
//
67
+
// Returns nil if this is called from any other than normal event hooks such as RequestHeaders, RequestBody, ResponseHeaders, and ResponseBody.
68
+
NewScheduler() Scheduler
69
+
// ContinueRequest continues the request processing after the Stop variants are returned from the normal event hooks such as RequestHeaders, RequestBody, ResponseHeaders, and ResponseBody.
70
+
// Mainly this is intented to be used during the HttpFilter.Scheduled method being called.
71
+
ContinueRequest()
72
+
// ContinueResponse is the same as ContinueRequest but for the response processing.
73
+
ContinueResponse()
74
+
}
75
+
76
+
// Scheduler is an interface that can be used to schedule a generic event to the correct Envoy worker thread.
77
+
//
78
+
// This is created via [EnvoyHttpFilter.NewScheduler] and can be passed across Goroutines.
79
+
typeSchedulerinterface {
80
+
// Commit commits the event to the Envoy filter on the correct worker thread.
81
+
// The eventID is a unique identifier for the event, and it can be used to distinguish between different events.
82
+
Commit(eventIDuint64)
83
+
Close()
62
84
}
63
85
64
86
// HttpFilter is an interface that represents each Http request.
0 commit comments