config

package
v0.0.0-...-14fead7 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Logger log instance, if nil will use default nop logger
	Logger *zap.Logger
	// Debug whether to enable debug mode
	Debug bool
	// OverwriteExisting whether to overwrite existing files, default false
	// When false, returns error if file already exists
	// When true, directly overwrites existing file
	OverwriteExisting bool
	// PageSizeBytes page size in bytes, when serialized data exceeds this size, pagination is performed
	// Default 0 means no pagination. Recommended value like 50MB = 50 * 1024 * 1024
	PageSizeBytes int64
}

Config contains SDK common configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

func NewDebugConfig

func NewDebugConfig() *Config

NewDebugConfig returns configuration with debug mode enabled

func (*Config) GetLogger

func (c *Config) GetLogger() *zap.Logger

GetLogger gets logger instance

func (*Config) WithDebug

func (c *Config) WithDebug(debug bool) *Config

WithDebug sets debug mode

func (*Config) WithDevelopmentLogger

func (c *Config) WithDevelopmentLogger() *Config

WithDevelopmentLogger set debug logger

func (*Config) WithLogger

func (c *Config) WithLogger(logger *zap.Logger) *Config

WithLogger sets custom logger

func (*Config) WithOverwriteExisting

func (c *Config) WithOverwriteExisting(overwrite bool) *Config

WithOverwriteExisting sets whether to overwrite existing files

func (*Config) WithPageSize

func (c *Config) WithPageSize(sizeBytes int64) *Config

WithPageSize sets page size (bytes)

func (*Config) WithPageSizeMB

func (c *Config) WithPageSizeMB(sizeMB int64) *Config

WithPageSizeMB sets page size (MB)

func (*Config) WithProductionLogger

func (c *Config) WithProductionLogger() *Config

WithProductionLogger sets production environment logger

type MeteringAWSConfig

type MeteringAWSConfig struct {
	AssumeRoleARN    string `yaml:"assume-role-arn,omitempty" toml:"assume-role-arn,omitempty" json:"assume-role-arn,omitempty" reloadable:"false"`
	S3ForcePathStyle bool   `` /* 129-byte string literal not displayed */
	AccessKey        string `yaml:"access-key,omitempty" toml:"access-key,omitempty" json:"access-key,omitempty" reloadable:"false"`
	SecretAccessKey  string `yaml:"secret-access-key,omitempty" toml:"secret-access-key,omitempty" json:"secret-access-key,omitempty" reloadable:"false"`
	SessionToken     string `yaml:"session-token,omitempty" toml:"session-token,omitempty" json:"session-token,omitempty" reloadable:"false"`
}

MeteringAWSConfig AWS S3 specific configuration for high-level config

type MeteringAzureConfig

type MeteringAzureConfig struct {
	AccountName string `yaml:"account-name,omitempty" toml:"account-name,omitempty" json:"account-name,omitempty" reloadable:"false"`
	AccountKey  string `yaml:"account-key,omitempty" toml:"account-key,omitempty" json:"account-key,omitempty" reloadable:"false"`
	SASToken    string `yaml:"sas-token,omitempty" toml:"sas-token,omitempty" json:"sas-token,omitempty" reloadable:"false"`
}

MeteringAzureConfig Azure Blob Storage specific configuration for high-level config

type MeteringConfig

type MeteringConfig struct {
	// Storage provider type: s3, oss, localfs, etc.
	Type storage.ProviderType `yaml:"type,omitempty" toml:"type,omitempty" json:"type,omitempty" reloadable:"false"`
	// Storage region
	Region string `yaml:"region,omitempty" toml:"region,omitempty" json:"region,omitempty" reloadable:"false"`
	// Storage bucket/container name
	Bucket string `yaml:"bucket,omitempty" toml:"bucket,omitempty" json:"bucket,omitempty" reloadable:"false"`
	// Path prefix for all stored files
	Prefix string `yaml:"prefix,omitempty" toml:"prefix,omitempty" json:"prefix,omitempty" reloadable:"false"`
	// Custom endpoint for S3-compatible services
	Endpoint string `yaml:"endpoint,omitempty" toml:"endpoint,omitempty" json:"endpoint,omitempty" reloadable:"false"`

	// Cloud-specific configurations
	AWS     *MeteringAWSConfig     `yaml:"aws,omitempty" toml:"aws,omitempty" json:"aws,omitempty" reloadable:"false"`
	OSS     *MeteringOSSConfig     `yaml:"oss,omitempty" toml:"oss,omitempty" json:"oss,omitempty" reloadable:"false"`
	Azure   *MeteringAzureConfig   `yaml:"azure,omitempty" toml:"azure,omitempty" json:"azure,omitempty" reloadable:"false"`
	LocalFS *MeteringLocalFSConfig `yaml:"localfs,omitempty" toml:"localfs,omitempty" json:"localfs,omitempty" reloadable:"false"`

	// Business-specific configurations
	// Shared pool cluster ID for sharedpool type metadata
	SharedPoolID string `yaml:"shared-pool-id,omitempty" toml:"shared-pool-id,omitempty" json:"shared-pool-id,omitempty" reloadable:"false"`
}

MeteringConfig represents a high-level configuration for metering SDK It combines storage provider configuration with business-specific settings

func NewFromURI

func NewFromURI(uriStr string) (*MeteringConfig, error)

NewFromURI creates a new MeteringConfig from a URI string. URI format: [scheme]://[bucket]/[prefix]?[parameters] Examples:

  • s3://my-bucket/data?region-id=us-east-1&endpoint=https://s3.example.com
  • oss://my-bucket/logs?region-id=oss-ap-southeast-1&access-key=AKSKEXAMPLE
  • azure://my-container/prefix?account-name=acct&account-key=key&endpoint=https://acct.blob.core.windows.net
  • localfs:///data/storage/logs?create-dirs=true&permissions=0755

Supported schemes: s3, oss, azure (alias: azblob), localfs, file Common parameters: region-id/region, endpoint, shared-pool-id AWS/S3 parameters: access-key, secret-access-key, session-token, assume-role-arn/role-arn, s3-force-path-style/force-path-style OSS parameters: access-key, secret-access-key, session-token, assume-role-arn/role-arn Azure parameters: account-name, account-key, sas-token LocalFS parameters: create-dirs, permissions

func NewMeteringConfig

func NewMeteringConfig() *MeteringConfig

NewMeteringConfig creates a new MeteringConfig with default values

func (*MeteringConfig) GetSharedPoolID

func (mc *MeteringConfig) GetSharedPoolID() string

GetSharedPoolID gets the shared pool cluster ID

func (*MeteringConfig) ToProviderConfig

func (mc *MeteringConfig) ToProviderConfig() *storage.ProviderConfig

ToProviderConfig converts MeteringConfig to storage.ProviderConfig

func (*MeteringConfig) ToURI

func (mc *MeteringConfig) ToURI() string

ToURI converts MeteringConfig to a URI string. URI format: [scheme]://[bucket]/[prefix]?[parameters] Examples:

  • s3://my-bucket/data?region-id=us-east-1&endpoint=https://s3.example.com
  • oss://my-bucket/logs?region-id=oss-ap-southeast-1&access-key=AKSKEXAMPLE
  • azure://my-container/prefix?account-name=acct&account-key=key&endpoint=https://acct.blob.core.windows.net
  • localfs:///data/storage/logs?create-dirs=true&permissions=0755

func (*MeteringConfig) WithAWSConfig

func (mc *MeteringConfig) WithAWSConfig(awsConfig *MeteringAWSConfig) *MeteringConfig

WithAWSConfig sets AWS specific configuration

func (*MeteringConfig) WithAWSRoleARN

func (mc *MeteringConfig) WithAWSRoleARN(roleARN string) *MeteringConfig

WithAWSRoleARN sets the AWS IAM role ARN for assume role

func (*MeteringConfig) WithAzure

func (mc *MeteringConfig) WithAzure(accountName, container string) *MeteringConfig

WithAzure configures for Azure Blob Storage

func (*MeteringConfig) WithAzureAccountKey

func (mc *MeteringConfig) WithAzureAccountKey(accountName, container, accountKey string) *MeteringConfig

WithAzureAccountKey configures for Azure Blob Storage with account key

func (*MeteringConfig) WithAzureConfig

func (mc *MeteringConfig) WithAzureConfig(azureConfig *MeteringAzureConfig) *MeteringConfig

WithAzureConfig sets Azure specific configuration

func (*MeteringConfig) WithAzureSASToken

func (mc *MeteringConfig) WithAzureSASToken(accountName, container, sasToken string) *MeteringConfig

WithAzureSASToken configures for Azure Blob Storage with SAS token

func (*MeteringConfig) WithEndpoint

func (mc *MeteringConfig) WithEndpoint(endpoint string) *MeteringConfig

WithEndpoint sets the custom endpoint

func (*MeteringConfig) WithLocalFS

func (mc *MeteringConfig) WithLocalFS(basePath string) *MeteringConfig

WithLocalFS configures for local filesystem storage

func (*MeteringConfig) WithLocalFSConfig

func (mc *MeteringConfig) WithLocalFSConfig(localConfig *MeteringLocalFSConfig) *MeteringConfig

WithLocalFSConfig sets LocalFS specific configuration

func (*MeteringConfig) WithOSS

func (mc *MeteringConfig) WithOSS(region, bucket string) *MeteringConfig

WithOSS configures for Alibaba Cloud OSS storage

func (*MeteringConfig) WithOSSAssumeRole

func (mc *MeteringConfig) WithOSSAssumeRole(region, bucket, roleARN string) *MeteringConfig

WithOSSAssumeRole configures for Alibaba Cloud OSS storage with assume role

func (*MeteringConfig) WithOSSConfig

func (mc *MeteringConfig) WithOSSConfig(ossConfig *MeteringOSSConfig) *MeteringConfig

WithOSSConfig sets OSS specific configuration

func (*MeteringConfig) WithOSSRoleARN

func (mc *MeteringConfig) WithOSSRoleARN(roleARN string) *MeteringConfig

WithOSSRoleARN sets the Alibaba Cloud OSS role ARN for assume role

func (*MeteringConfig) WithPrefix

func (mc *MeteringConfig) WithPrefix(prefix string) *MeteringConfig

WithPrefix sets the path prefix

func (*MeteringConfig) WithS3

func (mc *MeteringConfig) WithS3(region, bucket string) *MeteringConfig

WithS3 configures for AWS S3 storage

func (*MeteringConfig) WithS3AssumeRole

func (mc *MeteringConfig) WithS3AssumeRole(region, bucket, roleARN string) *MeteringConfig

WithS3AssumeRole configures for AWS S3 storage with assume role

func (*MeteringConfig) WithSharedPoolID

func (mc *MeteringConfig) WithSharedPoolID(poolID string) *MeteringConfig

WithSharedPoolID sets the shared pool cluster ID

type MeteringLocalFSConfig

type MeteringLocalFSConfig struct {
	BasePath    string `yaml:"base-path,omitempty" toml:"base-path,omitempty" json:"base-path,omitempty" reloadable:"false"`
	CreateDirs  bool   `yaml:"create-dirs,omitempty" toml:"create-dirs,omitempty" json:"create-dirs,omitempty" reloadable:"false"`
	Permissions string `yaml:"permissions,omitempty" toml:"permissions,omitempty" json:"permissions,omitempty" reloadable:"false"`
}

MeteringLocalFSConfig local filesystem specific configuration for high-level config

type MeteringOSSConfig

type MeteringOSSConfig struct {
	AssumeRoleARN   string `yaml:"assume-role-arn,omitempty" toml:"assume-role-arn,omitempty" json:"assume-role-arn,omitempty" reloadable:"false"`
	AccessKey       string `yaml:"access-key,omitempty" toml:"access-key,omitempty" json:"access-key,omitempty" reloadable:"false"`
	SecretAccessKey string `yaml:"secret-access-key,omitempty" toml:"secret-access-key,omitempty" json:"secret-access-key,omitempty" reloadable:"false"`
	SessionToken    string `yaml:"session-token,omitempty" toml:"session-token,omitempty" json:"session-token,omitempty" reloadable:"false"`
}

MeteringOSSConfig Alibaba Cloud OSS specific configuration for high-level config

Jump to

Keyboard shortcuts

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