Skip to content

samber/go-quickwit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A Go ingestion client for Quickwit

tag Go Version GoDoc Build Status Go report Coverage Contributors License

A Quickwit push client for Go. See slog-quickwit for a slog handler implementation.

If you're looking for a search library or Quickwit management interface, check the official library.

πŸš€ Install

go get github.com/samber/go-quickwit

This library is v0 and follows SemVer strictly. Some breaking changes might be made to exported APIs before v1.0.0.

πŸ’‘ Spec

GoDoc: https://pkg.go.dev/github.com/samber/go-quickwit

type Config struct {
	URL    string
	Client http.Client

	IndexID string

	BatchWait  time.Duration
	BatchBytes int
	Commit     CommitMode   // either quickwit.Auto, quickwit.WaitFor or quickwit.Force

	BackoffConfig BackoffConfig
	Timeout       time.Duration
}

type BackoffConfig struct {
	// start backoff at this level
	MinBackoff time.Duration
	// increase exponentially to this level
	MaxBackoff time.Duration
	// give up after this many; zero means infinite retries
	MaxRetries int
}

Example

First, start Quickwit:

docker-compose up -d
curl -X POST \
    'http://localhost:7280/api/v1/indexes' \
    -H 'Content-Type: application/yaml' \
    --data-binary @test-config.yaml

Then push logs:

import "github.com/samber/go-quickwit"

func main() {
	client := quickwit.NewWithDefault("http://localhost:7280", "my-index")
	defer client.Stop() // flush and stop

	for i := 0; i < 10; i++ {
		client.Push(map[string]any{
			"timestamp": time.Now().Unix(),
			"message":   fmt.Sprintf("hello %d", i),
		})
		time.Sleep(1 * time.Second)
	}
}

🀝 Contributing

Don't hesitate ;)

# start quickwit
docker-compose up -d
curl -X POST \
    'http://localhost:7280/api/v1/indexes' \
    -H 'Content-Type: application/yaml' \
    --data-binary @test-config.yaml

# Install some dev dependencies
make tools

# Run tests
make test
# or
make watch-test

πŸ‘€ Contributors

Contributors

πŸ’« Show your support

Give a ⭐️ if this project helped you!

GitHub Sponsors

πŸ“ License

Copyright Β© 2024 Samuel Berthe.

This project is MIT licensed.