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.
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.
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
}
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)
}
}
- Ping me on Twitter @samuelberthe (DMs, mentions, whatever :))
- Fork the project
- Fix open issues or request new features
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
Give a βοΈ if this project helped you!
Copyright Β© 2024 Samuel Berthe.
This project is MIT licensed.