Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
github.com/mecenat/solr
A Solr client written in Go
Designed for Solr 8.5 (Should support earlier versions as well)
Provides clients for Solr's Request API, Schema API & Core Admin API
Currently supports only JSON and basic CRUDL actions.
go get -u github.com/mecenat/solr
To create a new solr Client you need first to create a Connection. To create a Connection you need the host location (e.g. http://localhost:8983), the core name, and a http client (e.g. http.DefaultClient). Sending your own client could be useful when you need to wrap the client with another service, for example if you want to use AWS's X-Ray service to trace your API's calls.
When using a single server:
package main
import "github.com/mecenat/solr"
func main() {
conn, err := solr.NewConnection("host", "core", http.DefaultClient)
if err != nil {
...
}
slr, err := solr.NewSingleClient(conn)
if err != nil {
...
}
When using a the Primary-Replica paradigm:
package main
import "github.com/mecenat/solr"
func main() {
primaryConn, err := solr.NewConnection("primaryHost", "core", http.DefaultClient)
if err != nil {
...
}
replicaConn, err := solr.NewConnection("replicaHost", "core", http.DefaultClient)
if err != nil {
...
}
slr, err := solr.NewPrimaryReplicaClient(primaryConn, replicaConn)
if err != nil {
...
}
Aside from the normal Connection you can you a RetryableConnection which implements Hashicorp's retryable HttpClient specifying the max timeout and provide that connection to the clients.
package main
import "github.com/mecenat/solr"
func main() {
retConn, err := solr.NewRetryableConnection("host", "core", http.DefaultClient, 500*time.Millisecond)
if err != nil {
...
}
slr, err := solr.NewSingleClient(retConn)
if err != nil {
...
}
To access Solr's Core Admin API you need to create a separate client as follows:
package main
import "github.com/mecenat/solr"
func main() {
ctx := context.Background()
ca, err := solr.NewCoreAdmin(ctx, "host", http.DefaultClient)
if err != nil {
...
}
To access Solr's Schema API you also need a separate client as follows:
package main
import "github.com/mecenat/solr"
func main() {
ctx := context.Background()
sa, err := solr.NewSchemaAPI(ctx, "host", "core", http.DefaultClient)
if err != nil {
...
}
MIT
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.