New()
This method creates a Milvus client that connects to a specific Milvus deployment.
func New(ctx context.Context, config *ClientConfig) (*Client, error)
Request Parameters
Parameter |
Description |
Type |
---|---|---|
|
Context for the current call to work. |
|
|
Client configurations. For details, refer to the ClientConfig section. |
|
ClientConfig
This struct type defines all possible client configuration items as follows:
type ClientConfig struct {
Address string // Remote address, "localhost:19530".
Username string // Username for auth.
Password string // Password for auth.
DBName string // DBName for this client.
EnableTLSAuth bool // Enable TLS Auth for transport security.
APIKey string // API key
RetryRateLimit *RetryRateLimitOption // option for retry on rate limit inteceptor
}
Parameter |
Description |
Type |
---|---|---|
|
Specifies the address of your Milvus deployment. |
|
|
Specifies a valid username for authentication. |
|
|
Specifies the password of the above user. |
|
|
Specifies the database to access. |
|
|
Specifies whether to connect with TLS authentication enabled. |
|
|
Specifies the retry rate limit in case the connection fails. For details, refer to the RetryRateLimitOption section. |
|
RetryRateLimitOption
This struct type defines the retry options for the connection.
type RetryRateLimitOption struct {
MaxRetry uint
MaxBackoff time.Duration
}
Parameter |
Description |
Type |
---|---|---|
|
Specifies the maximum number of times the client should retry the connection. |
|
|
Specifies the maximum back-off duration for the connection. |
|
Return
A Client
object.
Example
import (
"context"
"github.com/milvus-io/milvus/v2/milvusclient"
)
mclient, err := client.NewClient(context.Background(), client.ClientConfig{
Address: "http://localhost:19530",
})