Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: supplementary code comments #6

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions opengemini/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,67 @@ import (
)

const (
AuthTypeToken AuthType = iota
AuthTypePassword
// AuthTypePassword Basic Authentication with the provided username and password.
AuthTypePassword AuthType = iota
// AuthTypeToken Token Authentication with the provided token.
AuthTypeToken
)

// Client represents a openGemini client.
type Client interface {
// Ping check that status of cluster.
Ping(idx int) error
}

// Config is used to construct a openGemini Client instance.
type Config struct {
// AddressList Configure the service URL for the openGemini service.
// This parameter is required.
AddressList []*Address
AuthConfig *AuthConfig
// AuthConfig configuration information for authentication.
AuthConfig *AuthConfig
// BatchConfig configuration information for batch processing.
BatchConfig *BatchConfig
// GzipEnabled determines whether to use gzip for data transmission.
GzipEnabled bool
TlsEnabled bool
TlsConfig *tls.Config
// TlsEnabled determines whether to use TLS for data transmission.
TlsEnabled bool
// TlsConfig configuration information for tls.
TlsConfig *tls.Config
}

// Address configuration for providing service.
type Address struct {
// Host service ip or domain.
Host string
// Port exposed service port.
Port int
}

// AuthType type of identity authentication.
type AuthType int

// AuthConfig represents the configuration information for authentication.
type AuthConfig struct {
// AuthType type of identity authentication.
AuthType AuthType
// Username provided username when used AuthTypePassword.
Username string
// Password provided password when used AuthTypePassword.
Password string
Token string
// Token provided token when used AuthTypeToken.
Token string
}

// BatchConfig represents the configuration information for batch processing.
type BatchConfig struct {
// BatchInterval batch time interval that triggers batch processing. (unit: ms)
BatchInterval int
BatchSize int
// BatchSize batch size that triggers batch processing.
BatchSize int
}

// NewClient Creates a openGemini client instance
func NewClient(config *Config) (Client, error) {
return newClient(config)
}
3 changes: 2 additions & 1 deletion opengemini/client_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package opengemini

import "net/http"

func (c client) Ping(idx int) error {
// Ping check that status of cluster.
func (c *client) Ping(idx int) error {
serverUrl := c.serverUrls[idx]
resp, err := c.cli.Get(serverUrl + UrlPing)
if err != nil {
Expand Down
Loading