Documentation ¶
Overview ¶
Package write provides service and its stuff
Index ¶
- type Batch
- type BatchErrorCallback
- type Service
- func (w *Service) EncodePoints(points ...*write.Point) (string, error)
- func (w *Service) Flush()
- func (w *Service) HandleWrite(ctx context.Context, batch *Batch) error
- func (w *Service) SetBatchErrorCallback(cb BatchErrorCallback)
- func (w *Service) WriteBatch(ctx context.Context, batch *Batch) *http2.Error
- func (w *Service) WriteURL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct { // lines to send Batch string // retry attempts so far RetryAttempts uint // true if it was removed from queue Evicted bool // time when this batch expires Expires time.Time }
Batch holds information for sending points batch
type BatchErrorCallback ¶ added in v2.5.0
BatchErrorCallback is synchronously notified in case non-blocking write fails. It returns true if WriteAPI should continue with retrying, false will discard the batch.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is responsible for reliable writing of batches
func NewService ¶
func NewService(org string, bucket string, httpService http2.Service, options *write.Options) *Service
NewService creates new write service
func (*Service) EncodePoints ¶
EncodePoints creates line protocol string from points
func (*Service) Flush ¶ added in v2.9.2
func (w *Service) Flush()
Flush sends batches from retry queue immediately, without retrying
func (*Service) HandleWrite ¶
HandleWrite handles writes of batches and handles retrying. Retrying is triggered by new writes, there is no scheduler. It first checks retry queue, because it has the highest priority. If there are some batches in retry queue, those are written and incoming batch is added to end of retry queue. Immediate write is allowed only in case there was success or not retryable error. Otherwise, delay is checked based on recent batch. If write of batch fails with retryable error (connection errors and HTTP code >= 429), Batch retry time is calculated based on #of attempts. If writes continues failing and # of attempts reaches maximum or total retry time reaches maxRetryTime, batch is discarded.
func (*Service) SetBatchErrorCallback ¶ added in v2.5.0
func (w *Service) SetBatchErrorCallback(cb BatchErrorCallback)
SetBatchErrorCallback sets callback allowing custom handling of failed writes. If callback returns true, failed batch will be retried, otherwise discarded.
func (*Service) WriteBatch ¶
WriteBatch performs actual writing via HTTP service