stream

package
v0.0.0-...-9a66a57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package stream provides a client and a server to consume search results as stream.

Index

Constants

View Source
const DefaultSSEPath = "/stream"

DefaultSSEPath is the path used by zoekt-webserver.

Variables

This section is empty.

Functions

func Server

func Server(searcher zoekt.Streamer) http.Handler

Server returns an http.Handler which is the server side of StreamSearch.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for StreamSearch. Do not create directly, call NewClient.

func NewClient

func NewClient(address string, httpClient *http.Client) *Client

NewClient returns a client which implements StreamSearch. If httpClient is nil, http.DefaultClient is used.

func (*Client) StreamSearch

func (c *Client) StreamSearch(ctx context.Context, q query.Q, opts *zoekt.SearchOptions, streamer zoekt.Sender) error

StreamSearch returns search results as stream by calling streamer.Send(event) for each event returned by the server.

Error events returned by the server are returned as error. Context errors are recreated and returned on a best-efforts basis.

type SenderFunc

type SenderFunc func(result *zoekt.SearchResult)

SenderFunc is an adapter to allow the use of ordinary functions as Sender. If f is a function with the appropriate signature, SenderFunc(f) is a Sender that calls f.

func (SenderFunc) Send

func (f SenderFunc) Send(result *zoekt.SearchResult)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL