Skip to main content

sse.go (package eai)

Source: sdks/go/sse.go. Back to the Go SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class SSEEvent​

SSEEvent is one Server-Sent Event.

Fields:

NameTypeRequiredDescription
Eventstringyes"message" when absent
Datastringyesdata lines joined with "\n"
IDstringyesValue of the id: line of the event, empty when absent.

SSEEvent.JSON​

JSON(v any) error

JSON unmarshals Data into v.

NameTypeDefaultRequiredDescription
vanyyesPointer the JSON of Data is decoded into.

Returns: error. Error of the call (a typed error of the SDK), nil on success.

Raises: error.

Class SSEStream​

SSEStream reads Server-Sent Events; "data: [DONE]" ends the stream. Always Close it.

SSEStream.Close​

Close() error

Close releases the connection.

This element takes no parameter.

Returns: error. Error of the call (a typed error of the SDK), nil on success.

Raises: error.

SSEStream.Err​

Err() error

Err returns the read error, if any.

This element takes no parameter.

Returns: error. Error of the call (a typed error of the SDK), nil on success.

Raises: error.

SSEStream.Event​

Event() SSEEvent

Event returns the current event.

This element takes no parameter.

Returns: SSEEvent. A SSEEvent: SSEEvent is one Server-Sent Event.

SSEStream.Next​

Next() bool

Next reads the next event; false at the end of the stream or on error (see Err).

This element takes no parameter.

Returns: bool. true when a new event is available through Event; false after [DONE], at the end of the body or on a read error.

Functions​

NewSSEStream​

NewSSEStream(body io.ReadCloser) *SSEStream

NewSSEStream wraps a response body.

NameTypeDefaultRequiredDescription
bodyio.ReadCloseryesRequest body, serialized as JSON.

Returns: *SSEStream. A SSEStream: SSEStream reads Server-Sent Events; "data: [DONE]" ends the stream. Always Close it.