Struct: eventstreamtesting.ServeEventStream

import "../ibm-cos-sdk-go-v2/service/internal/eventstreamtesting"

Overview

ServeEventStream provides serving EventStream messages from a HTTP server to the client. The events are sent sequentially to the client without delay.

Implemented Interfaces

types.AnalyticsFilter, v4.HTTPPresigner, s3.HTTPPresignerV4, types.MetricsFilter, s3.PresignPost, arn.S3ObjectLambdaARN, types.SelectObjectContentEventStream

Structure Field Summary collapse

Method Summary collapse

Structure Field Details

BiDirectional bool

ClientEvents []eventstream.Message

Events []eventstream.Message

ForceCloseAfter time.Duration

StaticResponse *StaticResponse

T *testing.T

Method Details

func (s ServeEventStream) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an HTTP client request



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// File 'service/internal/eventstreamtesting/server.go', line 101

func (s ServeEventStream) ServeHTTP(w http.ResponseWriter, r *http.Request) { if s.StaticResponse != nil { w.WriteHeader(s.StaticResponse.StatusCode) w.(http.Flusher).Flush() if _, err := w.Write(s.StaticResponse.Body); err != nil { s.T.Errorf("failed to write response body error: %v", err) } return } if s.BiDirectional { s.serveBiDirectionalStream(w, r) } else { s.serveReadOnlyStream(w, r) } }