buckt

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 13 Imported by: 3

README

Buckt Package Documentation

The Buckt package provides a flexible media storage service with optional integration for the Gin Gonic router. It enables you to manage and organize data using a robust and customizable file storage interface. You can configure it to log to files or the terminal, interact with an SQLite database, and access its services directly or via HTTP endpoints.

Go Report Card GoDoc License

Table of Contents

Features

  • Flexible Storage – Store and manage media files with ease.
  • Gin Gonic Integration – Use with Gin for HTTP-based file management.
  • Logging Support – Log to files or the terminal for better debugging.
  • SQLite Support – Store metadata in an SQLite database.
  • Direct & HTTP Access – Interact with Buckt programmatically or via API.

Getting Started

You can install the package using go get:

go get github.com/Rhaqim/buckt

Usage

Configuration Options

The Config struct holds the configuration options for the Buckt package. It includes settings for the database, cache, logging, media directory, and flat namespaces.

  type Config struct {
    DB    DBConfig
    Cache CacheConfig
    Log   LogConfig

    MediaDir       string
    FlatNameSpaces bool
}
Database

By default Buckt uses an SQLite database to store metadata on the media files, optionally you can provide a custom database connection using the DB field in the Config struct. Gorm is used as the ORM to interact with the database. On instantiation it migrates the database schema for the files and folders tables.

The files table stores metadata information about the media files, such as the file name, size, and MIME type.

The folders table stores logical mappings of folders to put files in.

The DBConfig struct allows for BYODB (Bring Your Own Database) configurations. You can specify the database driver and provide a custom database connection. If not provided, a default SQLite connection will be used.

Note: Parent application handles closing the database connection.

  type DBConfig struct {
    Driver   DBDrivers
    Database *sql.DB
  }
Caching

The Buckt package supports caching using the CacheManager interface. You can provide a custom cache manager by implementing the interface and passing it to the Cache field in the BucktOptions struct. The application also uses LRUCache for file caching.

The CacheManager interface allows the application to manage cached values.

  type CacheManager interface {
    // Set a value in the cache for a given key.
    SetBucktValue(key string, value any) error

    // Get a value from the cache using a key.
    GetBucktValue(key string) (any, error)

    // Delete a key-value pair from the cache.
    DeleteBucktValue(key string) error
  }
Logging

The Buckt package supports logging to files and the terminal. By default the package would log to terminal. You can configure the logging settings in the BucktOptions. Provide the logTerminal field with a boolean value to enable or disable logging to the terminal. The logFile field should contain the path to the log file.

The Log struct allows the parent application to configure logging options.

  type Log struct {
    LogTerminal bool
    LogFile     string
    Debug       bool
  }

The rest of the configuration options are as follows:

  • MediaDir – The path to the media directory on the file system.
  • FlatNameSpacestrue for flat namespaces, false for hierarchical namespaces.

Initialization

To create a new instance of the Buckt package, use the New or Default function. It requires the BucktConfig struct as an argument. The New function returns a new instance of the Buckt package, while the Default function initializes the package with default settings.

import "github.com/Rhaqim/buckt"

func main() {
    // Create a new instance of the Buckt package
    client, err := buckt.Default()
    if err != nil {
        log.Fatal(err)
    }

    defer client.Close()

    // Use client for your operations...
}

Services

Direct Services

The Buckt package exposes the services directly via the Buckt interface. You can use the services to manage and organize data using a robust and customizable interface.

A detailed example for direct usage can be found in the Direct Example directory.

Client

The Buckt package includes an HTTP client that exposes its services via HTTP endpoints or a web interface. If the WebMode is set to API, the client can be used to interact with the Buckt services over HTTP. If set to UI, the client provides a web interface for users to interact with the services.Additionally the HTTP handler can be mounted to a parent server when mode is set to Mount.

You can try out the UI Example.

Or the API Example.

Run In Postman

Cloud Backend

The Buckt package can be integrated with cloud services like Amazon S3, Google Cloud Storage, or Azure Blob Storage as the backend storage solution. If you want to use a cloud service as the backend, you need to import the submodule for the specific cloud provider. If no backend is specified, Buckt will use the local file system as the default storage.

Explore detailed cloud integration examples:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	// Posstgres represents the Postgres database driver.
	Postgres = model.Postgres
	// SQLite represents the SQLite database driver.
	SQLite = model.SQLite
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend added in v1.2.0

type Backend = domain.FileBackend

Backend represents the file backend interface.

It defines methods for interacting with the file storage backend.

func LocalBackend added in v1.2.0

func LocalBackend() Backend

LocalBackend is a placeholder and is replaced with the actual local backend implementation.

Usecase: Selecting the local backend for migration.

backendConfig := BackendConfig{
 MigrationEnabled: true,
	Source: buckt.LocalBackend(),
	Target: aws.S3Backend(),
}

type BackendConfig added in v1.2.0

type BackendConfig struct {
	// Source is the current backend in use (e.g., local, S3).
	Source Backend

	// Target is the backup or primary backend to migrate to (e.g., S3, Azure).
	// If MigrationEnabled is false, this is ignored.
	Target Backend

	// MigrationEnabled enables dual-write migration mode.
	MigrationEnabled bool
}

BackendConfig holds the configuration for the file backend.

It includes the source and target backends for migration.

If only one backend is specified, it is used as the primary backend.

type CacheConfig added in v1.0.2

type CacheConfig struct {
	Manager domain.CacheManager
	FileCacheConfig
}

CacheConfig holds the configuration for the cache manager. It includes the cache manager instance and file cache configuration. Fields:

Manager: The cache manager instance.
FileCacheConfig: The file cache configuration.

type Client added in v1.2.0

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

func Default

func Default(opts ...ConfigFunc) (*Client, error)

Default initializes a new Buckt Client with default configuration options. It accepts a variadic number of ConfigFunc options to customize the BucktConfig.

The default configuration includes: - LogConfig with LogTerminal set to true, LogFile set to "logs", and Debug set to true. - MediaDir set to "media". - FlatNameSpaces set to true.

Parameters: - opts: A variadic number of ConfigFunc options to customize the BucktConfig.

Returns: - A pointer to the initialized Buckt Client. - An error if the Buckt Client could not be created.

func New

func New(conf Config, opts ...ConfigFunc) (*Client, error)

New initializes a new Buckt client with the provided configuration options. It accepts a Config struct and a variadic number of ConfigFunc options as arguments and returns a pointer to the initialized Buckt client.

Parameters: - conf: A Config struct containing the configuration options for the Buckt client. - opts: A variadic number of ConfigFunc options to customize the BucktConfig.

Returns: - A pointer to the initialized Buckt Client. - An error if the Buckt client could not be created.

func (*Client) Close added in v1.2.0

func (b *Client) Close()

Close closes the Buckt instance. It closes the database connection and the LRU cache.

func (*Client) DeleteFile added in v1.2.0

func (b *Client) DeleteFile(file_id string) (string, error)

DeleteFile deletes a file associated with the given user ID and file ID. It returns an error if the deletion fails.

Parameters:

  • file_id: The ID of the file to be deleted.

Returns:

  • error: An error if the file deletion fails, otherwise nil.

func (*Client) DeleteFileContext added in v1.4.0

func (b *Client) DeleteFileContext(ctx context.Context, file_id string) (string, error)

DeleteFileContext deletes a file associated with the given user ID and file ID. It returns an error if the deletion fails.

Parameters:

  • ctx: The context for the operation.
  • file_id: The ID of the file to be deleted.

Returns:

  • error: An error if the file deletion fails, otherwise nil.

func (*Client) DeleteFilePermanently added in v1.2.0

func (b *Client) DeleteFilePermanently(file_id string) (string, error)

DeleteFilePermanently deletes a file associated with the given user ID and file ID. It returns an error if the deletion fails.

Parameters:

  • file_id: The ID of the file to be deleted.

Returns:

  • error: An error if the file deletion fails, otherwise nil.

func (*Client) DeleteFilePermanentlyContext added in v1.4.0

func (b *Client) DeleteFilePermanentlyContext(ctx context.Context, file_id string) (string, error)

DeleteFilePermanentlyContext deletes a file associated with the given user ID and file ID. It returns an error if the deletion fails.

Parameters:

  • ctx: The context for the operation.
  • file_id: The ID of the file to be deleted.

Returns:

  • error: An error if the file deletion fails, otherwise nil.

func (*Client) DeleteFolder added in v1.2.0

func (b *Client) DeleteFolder(folder_id string) (string, error)

DeleteFolder soft deletes a folder with the given folder_id using the folderService. It returns an error if the deletion fails.

Parameters:

  • folder_id: The ID of the folder to be deleted.

Returns:

  • error: An error if the deletion fails, otherwise nil.

func (*Client) DeleteFolderContext added in v1.4.0

func (b *Client) DeleteFolderContext(ctx context.Context, folder_id string) (string, error)

DeleteFolderContext soft deletes a folder with the given folder_id using the folderService. It returns an error if the deletion fails.

Parameters:

  • ctx: The context for the operation.
  • folder_id: The ID of the folder to be deleted.

Returns:

  • error: An error if the deletion fails, otherwise nil.

func (*Client) DeleteFolderPermanently added in v1.2.0

func (b *Client) DeleteFolderPermanently(user_id, folder_id string) (string, error)

DeleteFolderPermanently deletes a folder permanently for a given user. It takes the user ID and folder ID as parameters and returns an error if the operation fails.

Parameters:

  • user_id: The ID of the user who owns the folder.
  • folder_id: The ID of the folder to be deleted.

Returns:

  • error: An error object if the deletion fails, otherwise nil.

func (*Client) DeleteFolderPermanentlyContext added in v1.4.0

func (b *Client) DeleteFolderPermanentlyContext(ctx context.Context, user_id, folder_id string) (string, error)

DeleteFolderPermanentlyContext deletes a folder permanently for a given user. It takes the user ID and folder ID as parameters and returns an error if the operation fails.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user who owns the folder.
  • folder_id: The ID of the folder to be deleted.

Returns:

  • error: An error object if the deletion fails, otherwise nil.

func (*Client) GetFile added in v1.2.0

func (b *Client) GetFile(file_id string) (*model.FileModel, error)

GetFile retrieves a file based on the provided file ID. It returns the file data and an error, if any occurred during the retrieval process.

Parameters:

  • file_id: A string representing the unique identifier of the file to be retrieved.

Returns:

  • *model.FileModel: The file data.
  • error: An error object if an error occurred, otherwise nil.

func (*Client) GetFileContext added in v1.4.0

func (b *Client) GetFileContext(ctx context.Context, file_id string) (*model.FileModel, error)

GetFileContext retrieves a file based on the provided file ID. It returns the file data and an error, if any occurred during the retrieval process.

Parameters:

  • ctx: The context for the operation.
  • file_id: A string representing the unique identifier of the file to be retrieved.

Returns:

  • *model.FileModel: The file data.
  • error: An error object if an error occurred, otherwise nil.

func (*Client) GetFileStream added in v1.2.0

func (b *Client) GetFileStream(file_id string) (*model.FileModel, io.ReadCloser, error)

GetFileStream retrieves a file stream based on the provided file ID. It returns the file data and an error, if any occurred during the retrieval process.

Parameters:

  • file_id: A string representing the unique identifier of the file to be retrieved.

Returns:

  • *model.FileModel: The file structure containing metadata.
  • io.ReadCloser: An io.ReadCloser object representing the file stream
  • error: An error object if an error occurred, otherwise nil.

Note: The caller is responsible for closing the file stream after reading.

func (*Client) GetFileStreamContext added in v1.4.0

func (b *Client) GetFileStreamContext(ctx context.Context, file_id string) (*model.FileModel, io.ReadCloser, error)

GetFileStreamContext retrieves a file stream based on the provided file ID. It returns the file data and an error, if any occurred during the retrieval process.

Parameters:

  • ctx: The context for the operation.
  • file_id: A string representing the unique identifier of the file to be retrieved.

Returns:

  • *model.FileModel: The file structure containing metadata.
  • io.ReadCloser: An io.ReadCloser object representing the file stream
  • error: An error object if an error occurred, otherwise nil.

Note: The caller is responsible for closing the file stream after reading.

func (*Client) GetFolderWithContent added in v1.2.0

func (b *Client) GetFolderWithContent(user_id, folder_id string) (*model.FolderModel, error)

GetFolderWithContent retrieves a folder and its content.

Parameters:

  • user_id: The ID of the user who owns the folder.
  • folder_id: The ID of the folder to retrieve the content for.

Returns:

  • *model.FolderModel: The folder model containing the folder content.
  • error: An error if the folder content could not be retrieved.

func (*Client) GetFolderWithContentContext added in v1.4.0

func (b *Client) GetFolderWithContentContext(ctx context.Context, user_id, folder_id string) (*model.FolderModel, error)

GetFolderWithContentContext retrieves a folder and its content.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user who owns the folder.
  • folder_id: The ID of the folder to retrieve the content for.

Returns:

  • *model.FolderModel: The folder model containing the folder content.
  • error: An error if the folder content could not be retrieved.

func (*Client) ListFiles added in v1.2.0

func (b *Client) ListFiles(folder_id string) ([]model.FileModel, error)

ListFiles retrieves a list of files for a given folder.

Parameters:

  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FileModel: A list of files.
  • error: An error if the folder could not be retrieved.

func (*Client) ListFilesContext added in v1.4.0

func (b *Client) ListFilesContext(ctx context.Context, folder_id string) ([]model.FileModel, error)

ListFilesContext retrieves a list of files for a given folder.

Parameters:

  • ctx: The context for the operation.
  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FileModel: A list of files.
  • error: An error if the folder could not be retrieved.

func (*Client) ListFilesMetadata added in v1.4.1

func (b *Client) ListFilesMetadata(folder_id string) ([]model.FileModel, error)

ListFilesMetadata retrieves a list of files' metadata for a given folder.

Parameters:

  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FileModel: A list of files' metadata.
  • error: An error if the folder could not be retrieved.

func (*Client) ListFilesMetadataContext added in v1.4.1

func (b *Client) ListFilesMetadataContext(ctx context.Context, folder_id string) ([]model.FileModel, error)

ListFilesMetadataContext retrieves a list of files' metadata for a given folder.

Parameters:

  • ctx: The context for the operation.
  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FileModel: A list of files' metadata.
  • error: An error if the folder could not be retrieved.

func (*Client) ListFolders added in v1.2.0

func (b *Client) ListFolders(folder_id string) ([]model.FolderModel, error)

ListFolders retrieves a list of folders for a given folder.

Parameters:

  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FolderModel: A list of folders.
  • error: An error if the folder could not be retrieved.

func (*Client) ListFoldersContext added in v1.4.0

func (b *Client) ListFoldersContext(ctx context.Context, folder_id string) ([]model.FolderModel, error)

ListFoldersContext retrieves a list of folders for a given folder.

Parameters:

  • ctx: The context for the operation.
  • folder_id: The ID of the folder to retrieve.

Returns:

  • []model.FolderModel: A list of folders.
  • error: An error if the folder could not be retrieved.

func (*Client) MoveFile added in v1.2.0

func (b *Client) MoveFile(file_id string, new_parent_id string) error

MoveFile moves a file to a new parent directory.

Parameters:

  • file_id: The ID of the file to be updated.
  • new_parent_id: The new parent directory for the file.

Returns:

  • error: An error if the update operation fails, otherwise nil.

func (*Client) MoveFileContext added in v1.4.0

func (b *Client) MoveFileContext(ctx context.Context, file_id string, new_parent_id string) error

MoveFileContext moves a file to a new parent directory.

Parameters:

  • ctx: The context for the operation.
  • file_id: The ID of the file to be updated.
  • new_parent_id: The new parent directory for the file.

Returns:

  • error: An error if the update operation fails, otherwise nil.

func (*Client) MoveFolder added in v1.2.0

func (b *Client) MoveFolder(user_id, folder_id string, new_parent_id string) error

MoveFolder moves a folder to a new parent folder.

Parameters:

  • user_id: The ID of the user performing the operation.
  • folder_id: The ID of the folder to be moved.
  • new_parent_id: The ID of the new parent folder.

Returns:

  • error: An error if the operation fails, otherwise nil.

func (*Client) MoveFolderContext added in v1.4.0

func (b *Client) MoveFolderContext(ctx context.Context, user_id, folder_id string, new_parent_id string) error

MoveFolderContext moves a folder to a new parent folder.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user performing the operation.
  • folder_id: The ID of the folder to be moved.
  • new_parent_id: The ID of the new parent folder.

Returns:

  • error: An error if the operation fails, otherwise nil.

func (*Client) NewFolder added in v1.2.0

func (b *Client) NewFolder(user_id string, parent_id string, folder_name string, description string) (new_folder_id string, err error)

NewFolder creates a new folder for a user within a specified parent folder.

Parameters:

  • user_id: The ID of the user creating the folder.
  • parent_id: The ID of the parent folder where the new folder will be created.
  • folder_name: The name of the new folder.
  • description: A description of the new folder.

Returns:

  • The ID of the newly created folder.
  • An error if the operation fails.

func (*Client) NewFolderContext added in v1.4.0

func (b *Client) NewFolderContext(ctx context.Context, user_id string, parent_id string, folder_name string, description string) (new_folder_id string, err error)

NewFolderContext creates a new folder for a user within a specified parent folder.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user creating the folder.
  • parent_id: The ID of the parent folder where the new folder will be created.
  • folder_name: The name of the new folder.
  • description: A description of the new folder.

Returns:

  • The ID of the newly created folder.
  • An error if the operation fails.

func (*Client) RenameFolder added in v1.2.0

func (b *Client) RenameFolder(user_id, folder_id string, new_name string) error

RenameFolder renames a folder.

Parameters:

  • user_id: The ID of the user performing the operation.
  • folder_id: The ID of the folder to be renamed.
  • new_name: The new name for the folder.

Returns:

  • error: An error if the operation fails, otherwise nil.

func (*Client) RenameFolderContext added in v1.4.0

func (b *Client) RenameFolderContext(ctx context.Context, user_id, folder_id string, new_name string) error

RenameFolderContext renames a folder.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user performing the operation.
  • folder_id: The ID of the folder to be renamed.
  • new_name: The new name for the folder.

Returns:

  • error: An error if the operation fails, otherwise nil.

func (*Client) UploadFile added in v1.2.0

func (b *Client) UploadFile(user_id string, parent_id string, file_name string, content_type string, file_data []byte) (string, error)

UploadFile uploads a file to the specified user's bucket.

Parameters:

  • user_id: The ID of the user who owns the bucket.
  • parent_id: The ID of the parent directory where the file will be uploaded.
  • file_name: The name of the file to be uploaded.
  • content_type: The MIME type of the file.
  • file_data: The byte slice containing the file data.

Returns:

  • string: The ID of the newly created file.
  • error: An error if the file upload fails, otherwise nil.

func (*Client) UploadFileContext added in v1.4.0

func (b *Client) UploadFileContext(ctx context.Context, user_id string, parent_id string, file_name string, content_type string, file_data []byte) (string, error)

UploadFileContext uploads a file to the specified user's bucket.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user who owns the bucket.
  • parent_id: The ID of the parent directory where the file will be uploaded.
  • file_name: The name of the file to be uploaded.
  • content_type: The MIME type of the file.
  • file_data: The byte slice containing the file data.

Returns:

  • string: The ID of the newly created file.
  • error: An error if the file upload fails, otherwise nil.

func (*Client) UploadFileFromReader added in v1.4.0

func (b *Client) UploadFileFromReader(user_id string, parent_id string, file_name string, content_type string, file_data io.Reader) (string, error)

UploadFileFromReader uploads a file to the specified user's bucket from an io.Reader.

Parameters:

  • user_id: The ID of the user who owns the bucket.
  • parent_id: The ID of the parent directory where the file will be uploaded.
  • file_name: The name of the file to be uploaded.
  • content_type: The MIME type of the file.
  • file_data: An io.Reader containing the file data.

Returns:

  • string: The ID of the newly created file.
  • error: An error if the file upload fails, otherwise nil.

func (*Client) UploadFileFromReaderContext added in v1.4.0

func (b *Client) UploadFileFromReaderContext(ctx context.Context, user_id string, parent_id string, file_name string, content_type string, file_data io.Reader) (string, error)

UploadFileFromReaderContext uploads a file to the specified user's bucket from an io.Reader.

Parameters:

  • ctx: The context for the operation.
  • user_id: The ID of the user who owns the bucket.
  • parent_id: The ID of the parent directory where the file will be uploaded.
  • file_name: The name of the file to be uploaded.
  • content_type: The MIME type of the file.
  • file_data: An io.Reader containing the file data.

Returns:

  • string: The ID of the newly created file.
  • error: An error if the file upload fails, otherwise nil.

type Config added in v1.2.0

type Config struct {
	MediaDir       string
	FlatNameSpaces bool

	DB      DBConfig
	Cache   CacheConfig
	Log     LogConfig
	Backend BackendConfig
}

Config represents the configuration options for the Buckt application. It includes settings for logging, media directory, and standalone mode.

Fields:

DB: Database configuration.
Cache: Cache configuration.
Log: Configuration for logging.
MediaDir: Path to the directory where media files are stored.
FlatNameSpaces: Flag indicating whether the application should use flat namespaces when storing files.

type ConfigFunc

type ConfigFunc func(*Config)

ConfigFunc is a function type that takes a pointer to Config and modifies it.

func EnableMigration added in v1.4.0

func EnableMigration() ConfigFunc

EnableMigration enables dual-write migration mode in the Buckt application.

func FlatNameSpaces

func FlatNameSpaces(flat bool) ConfigFunc

FlatNameSpaces is a configuration function that sets the FlatNameSpaces option in the Config. When the flat parameter is true, it enables flat namespaces; otherwise, it disables them.

Parameters:

flat - a boolean value indicating whether to enable or disable flat namespaces.

Returns:

A ConfigFunc that applies the flat namespaces setting to a Config.

func MediaDir

func MediaDir(mediaDir string) ConfigFunc

MediaDir sets the directory path for media files in the Config. It takes a string parameter mediaDir which specifies the path to the media directory. It returns a ConfigFunc that updates the MediaDir field of Config.

func RegisterPrimaryBackend added in v1.2.0

func RegisterPrimaryBackend(backend Backend) ConfigFunc

RegisterPrimaryBackend registers the primary backend for the Buckt application.

func RegisterSecondaryBackend added in v1.2.0

func RegisterSecondaryBackend(backend Backend) ConfigFunc

RegisterSecondaryBackend registers the secondary backend for the Buckt application.

func WithCache

func WithCache(cache CacheConfig) ConfigFunc

WithCache is a configuration function that sets the cache configuration for the Config. It takes a CacheConfig instance as an argument and assigns it to the Cache field of Config.

Parameters:

  • cache: An instance of CacheConfig to be used for caching.

Returns:

  • A ConfigFunc that sets the CacheManager in the Config.

func WithDB

func WithDB(driver DBDrivers, db *sql.DB) ConfigFunc

WithDB is a configuration function that sets the database connection for the Config. It takes a *sql.DB as an argument and returns a ConfigFunc that assigns the provided database connection to the Config.

Parameters:

  • driver: A string representing the database driver name.
  • db: A pointer to an sql.DB instance representing the database connection.

Returns:

  • ConfigFunc: A function that takes a pointer to Config and sets its DB field.

func WithLog

func WithLog(log LogConfig) ConfigFunc

WithLog is a configuration function that sets the logger for the Config. It takes a Log instance as an argument and assigns it to the Log field of Config.

Parameters:

  • log: An instance of Log to be used for logging.

Returns:

  • A ConfigFunc that sets the Log field of Config.

type DBConfig

type DBConfig struct {
	Driver   DBDrivers
	Database *sql.DB
}

DBConfig holds the configuration for the database connection.

Fields:

Driver: A string representing the database driver name.
Database: A pointer to an sql.DB instance representing the database connection.

type DBDrivers

type DBDrivers = model.DBDrivers // Type alias

type FileCacheConfig added in v1.0.2

type FileCacheConfig struct {
	NumCounters int64
	MaxCost     int64
	BufferItems int64
}

FileCacheConfig holds the configuration for the file cache. It includes settings for the number of counters, maximum cost, and buffer items.

Fields:

NumCounters: The number of counters for the cache.
MaxCost: The maximum cost of the cache.
BufferItems: The number of items in the buffer.

func (*FileCacheConfig) Validate added in v1.0.2

func (f *FileCacheConfig) Validate()

Validate checks the configuration values for the file cache. It sets default values if the provided values are less than or equal to zero. The default values are:

NumCounters: 1e7 (10 million)
MaxCost: 1 << 30 (1 GB)
BufferItems: 64

If the values are already set to valid values, they remain unchanged. This function is useful for ensuring that the cache configuration is valid before using it in the application. It is typically called during the initialization of the cache manager.

type FileInfo added in v1.2.0

type FileInfo = model.FileInfo

FileInfo represents information about a file.

type LogConfig

type LogConfig struct {
	LogFile     string
	Silence     bool
	LogTerminal bool
	Logger      *log.Logger
}

LogConfig holds the configuration for logging in the application.

Fields:

LogFile: A string representing the log file path.
Silence: A boolean flag indicating whether to silence logs.
LogTerminal: A boolean flag indicating whether to log to the terminal.
Logger: A pointer to a log.Logger instance. If nil, a new logger will be created.

Directories

Path Synopsis
client
web module
cloud
aws module
azure module
gcp module
internal
pkg
web module

Jump to

Keyboard shortcuts

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