Documentation ¶
Index ¶
Constants ¶
const ( // MaxDocumentCount is the max number of documents that can be sent in one batch MaxDocumentCount = 1_000 DefaultDocumentCount = MaxDocumentCount DefaultFlushInterval = time.Second )
Variables ¶
This section is empty.
Functions ¶
func JSONConversion ¶ added in v0.22.6
JSONConversion converts any to a map[string]any using json.Marshal and then json.Unmarshal
Types ¶
type Config ¶
type Config struct { // BatchDocumentCount is the max document count to send in one request. Must be less than or equal to MaxDocumentCount BatchDocumentCount uint64 // Workers number of workers to use, defaults to 1. Workers uint64 // FlushInterval is the longest interval to wait before flushing buffered documents. FlushInterval time.Duration // ConversionFn is a function that converts the data in a Request into a map[string]any. // If not set, struct.Map() is used. ConversionFn func(any) (map[string]any, error) }
Config is a struct containing the configurable parameters for a Writer
type DocumentAdder ¶
type DocumentAdder interface {
AddDocuments(ctx context.Context, workspace, collection string, docs []interface{}) ([]openapi.DocumentStatus, error)
}
DocumentAdder is the interface used to write documents to Rockset, and is implemented by rockset.RockClient.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a helper package that writes documents to Rockset collections
func (*Writer) C ¶
C returns the Request channel, which is used to send documents to be added to Rockset.
func (*Writer) Run ¶
Run starts the reader loop that gets write requests from the channel and batches them so the workers can add them to the collection(s). It starts the number Worker specified in the Config, but more can be started it if the number of collections written to is large.
rs, _ := rockset.NewClient() w := writer.New(Config{}, rs.Documents) go w.Run(ctx) ... w.Stop() w.Wait()
func (*Writer) Stop ¶
func (w *Writer) Stop()
Stop cleanly stops the Writer and flushes any buffered item, and closes the Request channel.
func (*Writer) Wait ¶
func (w *Writer) Wait()
Wait waits until the reader loop and all workers have finished