Documentation ¶
Overview ¶
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Index ¶
- Variables
- func NewCircuitBreaker(graceDuration, doomDuration time.Duration) *timeCircuitBreaker
- type CircuitBreaker
- type CircuitState
- type Client
- type ClientOptions
- type Compression
- type Decoder
- type Dispatcher
- type Document
- type Feeder
- type Generator
- type Id
- type Operation
- type Queue
- type Result
- type Stats
- type Status
- type Throttler
Constants ¶
This section is empty.
Variables ¶
var (
ErrMissingId = errors.New("no id specified")
)
Functions ¶
func NewCircuitBreaker ¶
Types ¶
type CircuitBreaker ¶
type CircuitBreaker interface { Success() Failure() State() CircuitState }
type CircuitState ¶
type CircuitState int
const ( // CircuitClosed represents a closed circuit. Documents are processed successfully CircuitClosed CircuitState = iota // CircuitHalfOpen represents a half-open circuit. Some errors have happend, but processing may still recover CircuitHalfOpen // CircuitOpen represents a open circuit. Something is broken. We should no longer process documents CircuitOpen )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a HTTP client for the /document/v1/ API.
type ClientOptions ¶
type ClientOptions struct { BaseURL string Timeout time.Duration Route string TraceLevel int Compression Compression Speedtest bool NowFunc func() time.Time }
ClientOptions specifices the configuration options of a feed client.
type Compression ¶
type Compression int
const ( CompressionAuto Compression = iota CompressionNone CompressionGzip )
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes documents from a JSON structure which is either an array of objects, or objects separated by newline.
func NewDecoder ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher dispatches documents from a queue to a Feeder.
func NewDispatcher ¶
func NewDispatcher(feeder Feeder, throttler Throttler, breaker CircuitBreaker, output io.Writer, verbose bool) *Dispatcher
func (*Dispatcher) Close ¶
func (d *Dispatcher) Close() error
Close waits for all inflight operations to complete and closes the dispatcher.
func (*Dispatcher) Enqueue ¶
func (d *Dispatcher) Enqueue(doc Document) error
func (*Dispatcher) Stats ¶
func (d *Dispatcher) Stats() Stats
type Document ¶
type Document struct { Id Id Condition string Body []byte Operation Operation Create bool // contains filtered or unexported fields }
Document represents a Vespa document operation.
type Id ¶
type Id struct { Type string Namespace string Number *int64 Group string UserSpecific string // contains filtered or unexported fields }
Id represents a Vespa document ID.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is a generic wrapper around a doubly linked list.
type Result ¶
type Result struct { Err error Id Id Trace string Body []byte Status Status HTTPStatus int Latency time.Duration BytesSent int64 BytesRecv int64 }
Result represents the result of a feeding operation.
type Stats ¶
type Stats struct { // Number of operations passed to the feeder by the user, not counting retries. Operations int64 // Number of responses received, grouped by the HTTP status code. Requests that do not receive a response (i.e. no // status code) are not counted. ResponsesByCode map[int]int64 // Number of requests made, including retries. Requests int64 // Number of responses received. Responses int64 // Number of transport layer errors. Errors int64 // Number of requests currently in-flight. Inflight int64 // Sum of response latency TotalLatency time.Duration // Lowest recorded response latency MinLatency time.Duration // Highest recorded response latency MaxLatency time.Duration // Total bytes sent BytesSent int64 // Total bytes received BytesRecv int64 }
Stats represents feeding operation statistics.
func (Stats) AvgLatency ¶
AvgLatency returns the average latency for a request.
func (Stats) Successful ¶
func (Stats) Unsuccessful ¶
type Status ¶
type Status int
Status of a document operation.
const ( // StatusSuccess indicates a successful document operation. StatusSuccess Status = iota // StatusConditionNotMet indicates that the document operation itself was successful, but did not satisfy its // test-and-set condition. StatusConditionNotMet // StatusVespaFailure indicates that Vespa failed to process the document operation. StatusVespaFailure // StatusTransportFailure indicates that there was failure in the transport layer error while sending the document // operation to Vespa. StatusTransportFailure )
type Throttler ¶
type Throttler interface { // Sent notifies the the throttler that a document has been sent. Sent() // Success notifies the throttler that document operation succeeded. Success() // Throttled notifies the throttler that a throttling event occured while count documents were in-flight. Throttled(count int64) // TargetInflight returns the ideal number of documents to have in-flight now. TargetInflight() int64 }