postgres

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewPostgresClient

func NewPostgresClient(ctx context.Context, cfg Config) (
	*Client, error,
)

NewPostgresClient initiates the postgres Client.

func (Client) Close

func (c Client) Close(ctx context.Context) error

func (Client) GetActiveUserIDByActiveTokenID added in v0.0.2

func (c Client) GetActiveUserIDByActiveTokenID(ctx context.Context, id string) (string, error)

func (Client) GetDailySuccessfulResultsTimestampsByUserID added in v0.0.2

func (c Client) GetDailySuccessfulResultsTimestampsByUserID(ctx context.Context, userID string) ([]time.Time, error)

func (Client) WriteInputPrompt

func (c Client) WriteInputPrompt(ctx context.Context, requestID, userID, prompt string) error

func (Client) WriteModelResult

func (c Client) WriteModelResult(
	ctx context.Context, requestID, userID, predictionRaw, prediction, model string,
	usageTokensPrompt, usageTokensCompletions uint16,
) error

func (Client) WriteSuccessFlag added in v0.0.2

func (c Client) WriteSuccessFlag(ctx context.Context, requestID, userID, token string) error

type Config

type Config struct {
	DBHost             string `json:"db_host"`
	DBName             string `json:"db_name"`
	DBUser             string `json:"db_user"`
	DBPassword         string `json:"db_password"`
	TablePrompt        string `json:"table_prompt,omitempty"`
	TablePrediction    string `json:"table_prediction,omitempty"`
	TableSuccessStatus string `json:"table_success_status,omitempty"`
	TableUsers         string `json:"table_users,omitempty"`
	TableTokens        string `json:"table_tokens,omitempty"`
	SSLMode            string `json:"ssl_mode"`
}

Config configuration of the postgres Client.

func (Config) ConnectionString added in v0.0.2

func (cfg Config) ConnectionString() string

func (Config) Validate

func (cfg Config) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL