Skip to content

Commit

Permalink
chore: supplementary code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xuthus5 committed Nov 19, 2023
1 parent e013d0b commit 0be0e8b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
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

0 comments on commit 0be0e8b

Please sign in to comment.