options

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package options provides functional options pattern for SDK configuration. This follows AWS SDK, gRPC, and other industry-standard Go SDKs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyClientOptions

func ApplyClientOptions(cfg *ClientConfig, opts ...ClientOption)

ApplyClientOptions applies options to config.

func ApplyConnectorOptions

func ApplyConnectorOptions(cfg *ConnectorConfig, opts ...ConnectorOption)

ApplyConnectorOptions applies options to config.

func ApplyGRPCOptions

func ApplyGRPCOptions(cfg *GRPCConfig, opts ...GRPCOption)

ApplyGRPCOptions applies options to config.

func ApplyScanOptions

func ApplyScanOptions(cfg *ScanConfig, opts ...ScanOption)

ApplyScanOptions applies options to config.

Types

type ClientConfig

type ClientConfig struct {
	BaseURL          string
	APIKey           string
	AgentID          string // Agent ID for tracking which agent is pushing
	Timeout          time.Duration
	MaxRetries       int
	RetryDelay       time.Duration
	EnableRetryQueue bool
	RetryQueueDir    string
	Verbose          bool
}

ClientConfig holds the final client configuration.

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

DefaultClientConfig returns default client configuration.

type ClientOption

type ClientOption func(*ClientConfig)

ClientOption is a function that configures the client.

func WithAPIKey

func WithAPIKey(key string) ClientOption

WithAPIKey sets the API key.

func WithAgentID

func WithAgentID(id string) ClientOption

WithAgentID sets the agent ID for tracking which agent is pushing data.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL sets the API base URL.

func WithRetry

func WithRetry(maxRetries int, retryDelay time.Duration) ClientOption

WithRetry sets retry configuration.

func WithRetryQueue

func WithRetryQueue(dir string) ClientOption

WithRetryQueue enables the retry queue.

func WithTimeout

func WithTimeout(d time.Duration) ClientOption

WithTimeout sets the request timeout.

func WithVerbose

func WithVerbose(v bool) ClientOption

WithVerbose enables verbose logging.

type ConnectorConfig

type ConnectorConfig struct {
	Name       string
	Type       string
	BaseURL    string
	APIKey     string
	Token      string
	RateLimit  int
	BurstLimit int
	Timeout    time.Duration
	MaxRetries int
	RetryDelay time.Duration
	Verbose    bool
}

ConnectorConfig holds connector configuration.

func DefaultConnectorConfig

func DefaultConnectorConfig() *ConnectorConfig

DefaultConnectorConfig returns default connector configuration.

type ConnectorOption

type ConnectorOption func(*ConnectorConfig)

ConnectorOption is a function that configures a connector.

func WithConnectorBaseURL

func WithConnectorBaseURL(url string) ConnectorOption

WithConnectorBaseURL sets the base URL.

func WithConnectorName

func WithConnectorName(name string) ConnectorOption

WithConnectorName sets the connector name.

func WithConnectorRateLimit

func WithConnectorRateLimit(rps int, burst int) ConnectorOption

WithConnectorRateLimit sets rate limiting.

func WithConnectorToken

func WithConnectorToken(token string) ConnectorOption

WithConnectorToken sets the auth token.

func WithConnectorType

func WithConnectorType(t string) ConnectorOption

WithConnectorType sets the connector type.

type GRPCConfig

type GRPCConfig struct {
	Address            string
	APIKey             string
	AgentID            string // Agent ID for tracking
	UseTLS             bool
	InsecureSkipVerify bool
	CertFile           string
	Timeout            time.Duration
	KeepAliveTime      time.Duration
	KeepAliveTimeout   time.Duration
	MaxRecvMsgSize     int
	MaxSendMsgSize     int
	Verbose            bool
}

GRPCConfig holds gRPC transport configuration.

func DefaultGRPCConfig

func DefaultGRPCConfig() *GRPCConfig

DefaultGRPCConfig returns default gRPC configuration.

type GRPCOption

type GRPCOption func(*GRPCConfig)

GRPCOption is a function that configures gRPC transport.

func WithGRPCAPIKey

func WithGRPCAPIKey(key string) GRPCOption

WithGRPCAPIKey sets the API key.

func WithGRPCAddress

func WithGRPCAddress(addr string) GRPCOption

WithGRPCAddress sets the server address.

func WithGRPCAgentID

func WithGRPCAgentID(id string) GRPCOption

WithGRPCAgentID sets the agent ID.

func WithGRPCCert

func WithGRPCCert(certFile string) GRPCOption

WithGRPCCert sets the certificate file.

func WithGRPCKeepalive

func WithGRPCKeepalive(time, timeout time.Duration) GRPCOption

WithGRPCKeepalive sets keepalive parameters.

func WithGRPCTLS

func WithGRPCTLS(useTLS bool, insecureSkipVerify bool) GRPCOption

WithGRPCTLS configures TLS.

func WithGRPCTimeout

func WithGRPCTimeout(d time.Duration) GRPCOption

WithGRPCTimeout sets the timeout.

func WithGRPCVerbose

func WithGRPCVerbose(v bool) GRPCOption

WithGRPCVerbose enables verbose logging.

type ScanConfig

type ScanConfig struct {
	Target      string
	Branches    []string
	Exclude     []string
	Include     []string
	MaxDepth    int
	Timeout     time.Duration
	Concurrency int
	Verbose     bool
}

ScanConfig holds scan configuration.

func DefaultScanConfig

func DefaultScanConfig() *ScanConfig

DefaultScanConfig returns default scan configuration.

type ScanOption

type ScanOption func(*ScanConfig)

ScanOption is a function that configures a scan.

func WithScanBranches

func WithScanBranches(branches ...string) ScanOption

WithScanBranches sets branches to scan.

func WithScanConcurrency

func WithScanConcurrency(n int) ScanOption

WithScanConcurrency sets concurrency level.

func WithScanExclude

func WithScanExclude(patterns ...string) ScanOption

WithScanExclude sets paths to exclude.

func WithScanInclude

func WithScanInclude(patterns ...string) ScanOption

WithScanInclude sets paths to include.

func WithScanTarget

func WithScanTarget(target string) ScanOption

WithScanTarget sets the scan target.

func WithScanTimeout

func WithScanTimeout(d time.Duration) ScanOption

WithScanTimeout sets the timeout.

Jump to

Keyboard shortcuts

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