typesense

package
v0.0.0-...-91bbc0a Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClientInterface

type APIClientInterface interface {
	api.ClientWithResponsesInterface
	api.ClientInterface
}

type AliasInterface

type AliasInterface interface {
	Retrieve() (*api.CollectionAlias, error)
	Delete() (*api.CollectionAlias, error)
}

AliasInterface is a type for Alias API operations

type AliasesInterface

type AliasesInterface interface {
	Upsert(aliasName string, aliasSchema *api.CollectionAliasSchema) (*api.CollectionAlias, error)
	Retrieve() ([]*api.CollectionAlias, error)
}

AliasesInterface is a type for Aliases API operations

type Client

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

func NewClient

func NewClient(opts ...ClientOption) *Client

func (*Client) Alias

func (c *Client) Alias(aliasName string) AliasInterface

func (*Client) Aliases

func (c *Client) Aliases() AliasesInterface

func (*Client) Collection

func (c *Client) Collection(collectionName string) CollectionInterface

func (*Client) Collections

func (c *Client) Collections() CollectionsInterface

func (*Client) Health

func (c *Client) Health(timeout time.Duration) (bool, error)

func (*Client) Key

func (c *Client) Key(keyID int64) KeyInterface

func (*Client) Keys

func (c *Client) Keys() KeysInterface

func (*Client) Operations

func (c *Client) Operations() OperationsInterface

type ClientConfig

type ClientConfig struct {
	ServerURL                   string
	APIKey                      string
	ConnectionTimeout           time.Duration
	CircuitBreakerName          string
	CircuitBreakerMaxRequests   uint32
	CircuitBreakerInterval      time.Duration
	CircuitBreakerTimeout       time.Duration
	CircuitBreakerReadyToTrip   circuit.GoBreakerReadyToTripFunc
	CircuitBreakerOnStateChange circuit.GoBreakerOnStateChangeFunc
}

type ClientOption

type ClientOption func(*Client)

func WithAPIClient

func WithAPIClient(apiClient APIClientInterface) ClientOption

WithAPIClient sets low-level API client

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

WithAPIKey sets the API token.

func WithCircuitBreakerInterval

func WithCircuitBreakerInterval(interval time.Duration) ClientOption

WithCircuitBreakerInterval sets the cyclic period of the closed state for CircuitBreaker to clear the internal Counts, described in gobreaker documentation. If Interval is 0, CircuitBreaker doesn't clear the internal Counts during the closed state. Default value is 2 minutes.

func WithCircuitBreakerMaxRequests

func WithCircuitBreakerMaxRequests(maxRequests uint32) ClientOption

WithCircuitBreakerMaxRequests sets the maximum number of requests allowed to pass through when the CircuitBreaker is half-open. If MaxRequests is 0, CircuitBreaker allows only 1 request. Default value is 50 requests.

func WithCircuitBreakerName

func WithCircuitBreakerName(name string) ClientOption

WithCircuitBreakerName sets the name of the CircuitBreaker. Default value is "typesenseClient".

func WithCircuitBreakerOnStateChange

func WithCircuitBreakerOnStateChange(onStateChange circuit.GoBreakerOnStateChangeFunc) ClientOption

WithCircuitBreakerOnStateChange sets the function that is called whenever the state of CircuitBreaker changes.

func WithCircuitBreakerReadyToTrip

func WithCircuitBreakerReadyToTrip(readyToTrip circuit.GoBreakerReadyToTripFunc) ClientOption

WithCircuitBreakerReadyToTrip sets the function that is called with a copy of Counts whenever a request fails in the closed state. If ReadyToTrip returns true, CircuitBreaker will be placed into the open state. If ReadyToTrip is nil, default ReadyToTrip is used. Default ReadyToTrip returns true when number of requests more than 100 and the percent of failures is more than 50 percents.

func WithCircuitBreakerTimeout

func WithCircuitBreakerTimeout(timeout time.Duration) ClientOption

WithCircuitBreakerTimeout sets the period of the open state, after which the state of CircuitBreaker becomes half-open. If Timeout is 0, the timeout value of CircuitBreaker is set to 60 seconds. Default value is 1 minute.

func WithClientConfig

func WithClientConfig(config *ClientConfig) ClientOption

WithClientConfig allows to pass all configs at once

func WithConnectionTimeout

func WithConnectionTimeout(timeout time.Duration) ClientOption

WithConnectionTimeout sets the connection timeout of http client. Default value is 5 seconds.

func WithServer

func WithServer(serverURL string) ClientOption

WithServer sets the API server URL

type CollectionInterface

type CollectionInterface interface {
	Retrieve() (*api.CollectionResponse, error)
	Delete() (*api.CollectionResponse, error)
	Documents() DocumentsInterface
	Document(documentID string) DocumentInterface
	Overrides() OverridesInterface
	Override(overrideID string) OverrideInterface
	Synonyms() SynonymsInterface
	Synonym(synonymID string) SynonymInterface
	Update(schema *api.CollectionUpdateSchema) (*api.CollectionUpdateSchema, error)
}

CollectionInterface is a type for Collection API operations

type CollectionsInterface

type CollectionsInterface interface {
	Create(schema *api.CollectionSchema) (*api.CollectionResponse, error)
	Retrieve() ([]*api.CollectionResponse, error)
}

CollectionsInterface is a type for Collections API operations

type DocumentInterface

type DocumentInterface interface {
	Retrieve() (map[string]interface{}, error)
	Update(document interface{}) (map[string]interface{}, error)
	Delete() (map[string]interface{}, error)
}

type DocumentsInterface

type DocumentsInterface interface {
	// Create returns indexed document
	Create(document interface{}) (map[string]interface{}, error)
	// Update updates documents matching the filter_by condition
	Update(updateFields interface{}, params *api.UpdateDocumentsParams) (int, error)
	// Upsert returns indexed/updated document
	Upsert(document interface{}) (map[string]interface{}, error)
	// Delete returns number of deleted documents
	Delete(filter *api.DeleteDocumentsParams) (int, error)
	// Search performs document search in collection
	Search(params *api.SearchCollectionParams) (*api.SearchResult, error)
	// Export returns all documents from index in jsonl format
	Export() (io.ReadCloser, error)
	// Import returns json array. Each item of the response indicates
	// the result of each document present in the request body (in the same order).
	Import(documents []interface{}, params *api.ImportDocumentsParams) ([]*api.ImportDocumentResponse, error)
	// ImportJsonl accepts documents and returns result in jsonl format. Each line of the
	// response indicates the result of each document present in the
	// request body (in the same order).
	ImportJsonl(body io.Reader, params *api.ImportDocumentsParams) (io.ReadCloser, error)
}

DocumentsInterface is a type for Documents API operations

type HTTPError

type HTTPError struct {
	Status int
	Body   []byte
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type KeyInterface

type KeyInterface interface {
	Retrieve() (*api.ApiKey, error)
	Delete() (*api.ApiKey, error)
}

type KeysInterface

type KeysInterface interface {
	Create(key *api.ApiKeySchema) (*api.ApiKey, error)
	Retrieve() ([]*api.ApiKey, error)
}

type MultiSearchInterface

type MultiSearchInterface interface {
	Perform(searchParams *api.MultiSearchParams, commonSearchParams api.MultiSearchSearchesParameter) (*api.MultiSearchResult, error)
	PerformWithContentType(searchParams *api.MultiSearchParams, commonSearchParams api.MultiSearchSearchesParameter, contentType string) (*api.MultiSearchResponse, error)
}

type OperationsInterface

type OperationsInterface interface {
	Snapshot(snapshotPath string) (bool, error)
	Vote() (bool, error)
}

type OverrideInterface

type OverrideInterface interface {
	Retrieve() (*api.SearchOverride, error)
	Delete() (*api.SearchOverride, error)
}

OverrideInterface is a type for Search Override API operations

type OverridesInterface

type OverridesInterface interface {
	Upsert(overrideID string, overrideSchema *api.SearchOverrideSchema) (*api.SearchOverride, error)
	Retrieve() ([]*api.SearchOverride, error)
}

OverridesInterface is a type for Search Overrides API operations

type SynonymInterface

type SynonymInterface interface {
	// Retrieve a single search synonym
	Retrieve() (*api.SearchSynonym, error)
	// Delete a synonym associated with a collection
	Delete() (*api.SearchSynonym, error)
}

SynonymInterface is a type for Search Synonym API operations

type SynonymsInterface

type SynonymsInterface interface {
	// Create or update a synonym
	Upsert(synonymID string, synonymSchema *api.SearchSynonymSchema) (*api.SearchSynonym, error)
	// List all collection synonyms
	Retrieve() ([]*api.SearchSynonym, error)
}

SynonymsInterface is a type for Search Synonyms API operations

Directories

Path Synopsis
api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
circuit
Package circuit implements the Circuit Breaker pattern for http client.
Package circuit implements the Circuit Breaker pattern for http client.
circuit/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package test contains integration tests for the github.com/typesense/typesense-go/typesense package.
Package test contains integration tests for the github.com/typesense/typesense-go/typesense package.

Jump to

Keyboard shortcuts

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