storage

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package storage provides storage interfaces for Hockeypuck

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupInfo

type BackupInfo struct {
	Name       string    `json:"name"`
	Path       string    `json:"path"`
	Created    time.Time `json:"created"`
	Size       int64     `json:"size"`
	Compressed bool      `json:"compressed"`
	Checksum   string    `json:"checksum"`
	KeyCount   int64     `json:"key_count"`
}

BackupInfo represents backup information

type BackupStorage

type BackupStorage interface {
	Backup(ctx context.Context, destination string) error
	Restore(ctx context.Context, source string) error
	ListBackups() ([]BackupInfo, error)
}

BackupStorage provides backup capabilities

type CacheStats

type CacheStats struct {
	Hits        int64   `json:"hits"`
	Misses      int64   `json:"misses"`
	Entries     int64   `json:"entries"`
	Size        int64   `json:"size"`
	Evictions   int64   `json:"evictions"`
	HitRate     float64 `json:"hit_rate"`
	MemoryUsage int64   `json:"memory_usage"`
}

CacheStats represents cache statistics

type CacheStorage

type CacheStorage interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte, ttl time.Duration) error
	Delete(key string) error
	Clear() error
	Stats() CacheStats
}

CacheStorage provides caching capabilities

type CompressionStorage

type CompressionStorage interface {
	SetCompressionLevel(level int) error
	GetCompressionLevel() int
	CompressedSize() (int64, error)
	UncompressedSize() (int64, error)
	CompressionRatio() (float64, error)
}

CompressionStorage provides compression capabilities

type ConcurrentStorage

type ConcurrentStorage interface {
	Storage
	ReadLock() error
	ReadUnlock() error
	WriteLock() error
	WriteUnlock() error
	TryReadLock() bool
	TryWriteLock() bool
}

ConcurrentStorage provides safe concurrent access

type Config

type Config struct {
	Driver   string                 `toml:"driver"`
	Database string                 `toml:"database"`
	Host     string                 `toml:"host"`
	Port     int                    `toml:"port"`
	Username string                 `toml:"username"`
	Password string                 `toml:"password"`
	SSLMode  string                 `toml:"sslmode"`
	Options  map[string]interface{} `toml:"options"`
}

Config represents storage configuration

type Event

type Event struct {
	Type      EventType              `json:"type"`
	Timestamp time.Time              `json:"timestamp"`
	KeyID     string                 `json:"key_id,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
}

Event represents a storage event

type EventHandler

type EventHandler func(Event) error

EventHandler handles storage events

type EventType

type EventType string

EventType represents the type of storage event

const (
	EventKeyInserted EventType = "key_inserted"
	EventKeyUpdated  EventType = "key_updated"
	EventKeyDeleted  EventType = "key_deleted"
	EventStatsUpdate EventType = "stats_update"
)

type EventfulStorage

type EventfulStorage interface {
	Storage
	Subscribe(EventType, EventHandler) error
	Unsubscribe(EventType, EventHandler) error
	PublishEvent(Event) error
}

EventfulStorage extends Storage with event support

type Factory

type Factory interface {
	Create(config Config) (Storage, error)
	DriverName() string
	ConfigSchema() map[string]interface{}
}

Factory creates storage instances

type HealthChecker

type HealthChecker interface {
	HealthCheck(ctx context.Context) error
	HealthStatus() HealthStatus
}

HealthChecker provides health checking capabilities

type HealthStatus

type HealthStatus struct {
	Healthy      bool                   `json:"healthy"`
	LastCheck    time.Time              `json:"last_check"`
	Details      map[string]interface{} `json:"details,omitempty"`
	Errors       []string               `json:"errors,omitempty"`
	ResponseTime time.Duration          `json:"response_time"`
}

HealthStatus represents health status

type Identity

type Identity struct {
	ScopedDigest string     `json:"scoped_digest"`
	Packet       []byte     `json:"packet"`
	Creation     time.Time  `json:"creation"`
	Expiration   *time.Time `json:"expiration,omitempty"`
	State        int        `json:"state"`
	Ctime        time.Time  `json:"ctime"`
	Mtime        time.Time  `json:"mtime"`
	Keywords     []string   `json:"keywords,omitempty"`
}

Identity represents a user identity

type IndexInfo

type IndexInfo struct {
	Name     string    `json:"name"`
	Fields   []string  `json:"fields"`
	Unique   bool      `json:"unique"`
	Created  time.Time `json:"created"`
	Size     int64     `json:"size"`
	KeyCount int64     `json:"key_count"`
}

IndexInfo represents index information

type IndexStorage

type IndexStorage interface {
	CreateIndex(name string, fields []string) error
	DropIndex(name string) error
	ListIndexes() ([]IndexInfo, error)
	ReindexAll() error
}

IndexStorage provides indexing capabilities

type KeyReader

type KeyReader interface {
	io.Reader
	Next() (*Pubkey, error)
	Close() error
}

KeyReader provides streaming access to keys

type KeyWriter

type KeyWriter interface {
	io.Writer
	WriteKey(*Pubkey) error
	Close() error
}

KeyWriter provides streaming writing of keys

type MetricsCollector

type MetricsCollector interface {
	CollectMetrics() (map[string]interface{}, error)
	RegisterMetric(name string, collector func() interface{}) error
}

MetricsCollector provides metrics collection

type NoOpStorage

type NoOpStorage struct{}

NoOpStorage provides a no-operation storage implementation

func (*NoOpStorage) Close

func (n *NoOpStorage) Close() error

func (*NoOpStorage) Delete

func (n *NoOpStorage) Delete([]string) error

func (*NoOpStorage) FetchKeys

func (n *NoOpStorage) FetchKeys([]string) ([]*Pubkey, error)

func (*NoOpStorage) FetchKeysPrefix

func (n *NoOpStorage) FetchKeysPrefix(string) ([]*Pubkey, error)

func (*NoOpStorage) Healthy

func (n *NoOpStorage) Healthy() error

func (*NoOpStorage) Insert

func (n *NoOpStorage) Insert([]*Pubkey) error

func (*NoOpStorage) MatchMD5

func (n *NoOpStorage) MatchMD5([]string) ([]string, error)

func (*NoOpStorage) ModifiedSince

func (n *NoOpStorage) ModifiedSince(time.Time) ([]string, error)

func (*NoOpStorage) ReconState

func (n *NoOpStorage) ReconState() (ReconState, error)

func (*NoOpStorage) ReconStats

func (n *NoOpStorage) ReconStats() (*ReconStats, error)

func (*NoOpStorage) Stats

func (n *NoOpStorage) Stats() (*Stats, error)

func (*NoOpStorage) Update

func (n *NoOpStorage) Update(*Pubkey, *Pubkey) error

type PartitionCriteria

type PartitionCriteria struct {
	Type        PartitionType          `json:"type"`
	Field       string                 `json:"field"`
	Values      []interface{}          `json:"values,omitempty"`
	Ranges      []PartitionRange       `json:"ranges,omitempty"`
	HashBuckets int                    `json:"hash_buckets,omitempty"`
	Config      map[string]interface{} `json:"config,omitempty"`
}

PartitionCriteria represents partitioning criteria

type PartitionInfo

type PartitionInfo struct {
	Name      string            `json:"name"`
	Criteria  PartitionCriteria `json:"criteria"`
	KeyCount  int64             `json:"key_count"`
	Size      int64             `json:"size"`
	Created   time.Time         `json:"created"`
	LastWrite time.Time         `json:"last_write"`
}

PartitionInfo represents partition information

type PartitionRange

type PartitionRange struct {
	Start interface{} `json:"start"`
	End   interface{} `json:"end"`
	Name  string      `json:"name"`
}

PartitionRange represents a partition range

type PartitionType

type PartitionType string

PartitionType represents the type of partitioning

const (
	PartitionByRange PartitionType = "range"
	PartitionByList  PartitionType = "list"
	PartitionByHash  PartitionType = "hash"
	PartitionByDate  PartitionType = "date"
)

type PartitionedStorage

type PartitionedStorage interface {
	Storage
	CreatePartition(name string, criteria PartitionCriteria) error
	DropPartition(name string) error
	ListPartitions() ([]PartitionInfo, error)
	GetPartition(keyID string) (string, error)
}

PartitionedStorage provides partitioning capabilities

type Pubkey

type Pubkey struct {
	RFingerprint string     `json:"rfingerprint"`
	Creation     time.Time  `json:"creation"`
	Expiration   *time.Time `json:"expiration,omitempty"`
	State        int        `json:"state"`
	Packet       []byte     `json:"packet"`
	Ctime        time.Time  `json:"ctime"`
	Mtime        time.Time  `json:"mtime"`
	MD5          string     `json:"md5"`
	SHA256       string     `json:"sha256"`
	Size         int        `json:"size"`

	// Associated data
	Identities []*Identity  `json:"identities,omitempty"`
	SubKeys    []*SubKey    `json:"subkeys,omitempty"`
	Signatures []*Signature `json:"signatures,omitempty"`
}

Pubkey represents an OpenPGP public key

type ReadOnlyStorage

type ReadOnlyStorage interface {
	// Read operations only
	MatchMD5([]string) ([]string, error)
	ModifiedSince(time.Time) ([]string, error)
	FetchKeys([]string) ([]*Pubkey, error)
	FetchKeysPrefix(string) ([]*Pubkey, error)
	Stats() (*Stats, error)
	Healthy() error
	ReconStats() (*ReconStats, error)
	ReconState() (ReconState, error)
	Close() error
}

ReadOnlyStorage provides read-only access

type ReconState

type ReconState struct {
	Version   int                    `json:"version"`
	HTTPAddr  string                 `json:"http_addr"`
	ReconAddr string                 `json:"recon_addr"`
	Filters   []string               `json:"filters"`
	Stats     *ReconStats            `json:"stats"`
	Settings  map[string]interface{} `json:"settings"`
}

ReconState represents the recon state

type ReconStats

type ReconStats struct {
	Total       int64     `json:"total"`
	LastUpdate  time.Time `json:"last_update"`
	SyncStarted time.Time `json:"sync_started,omitempty"`
	SyncStatus  string    `json:"sync_status"`
}

ReconStats represents recon statistics

type ReplicationError

type ReplicationError struct {
	Timestamp time.Time `json:"timestamp"`
	PeerID    string    `json:"peer_id"`
	Error     string    `json:"error"`
	KeyID     string    `json:"key_id,omitempty"`
}

ReplicationError represents a replication error

type ReplicationPeer

type ReplicationPeer struct {
	ID       string `json:"id"`
	Address  string `json:"address"`
	Priority int    `json:"priority"`
	ReadOnly bool   `json:"read_only"`
}

ReplicationPeer represents a replication peer

type ReplicationPeerStatus

type ReplicationPeerStatus struct {
	ID         string        `json:"id"`
	Address    string        `json:"address"`
	Connected  bool          `json:"connected"`
	LastSync   time.Time     `json:"last_sync"`
	Lag        time.Duration `json:"lag"`
	ErrorCount int           `json:"error_count"`
	LastError  string        `json:"last_error,omitempty"`
}

ReplicationPeerStatus represents peer status

type ReplicationStatus

type ReplicationStatus struct {
	Active     bool                    `json:"active"`
	Peers      []ReplicationPeerStatus `json:"peers"`
	LastSync   time.Time               `json:"last_sync"`
	SyncErrors []ReplicationError      `json:"sync_errors,omitempty"`
	Stats      map[string]interface{}  `json:"stats"`
}

ReplicationStatus represents replication status

type ReplicationStorage

type ReplicationStorage interface {
	Storage
	StartReplication(peers []ReplicationPeer) error
	StopReplication() error
	ReplicationStatus() ReplicationStatus
}

ReplicationStorage provides replication capabilities

type SearchCriteria

type SearchCriteria struct {
	KeyIDs       []string   `json:"key_ids,omitempty"`
	Fingerprints []string   `json:"fingerprints,omitempty"`
	UserIDs      []string   `json:"user_ids,omitempty"`
	Emails       []string   `json:"emails,omitempty"`
	Keywords     []string   `json:"keywords,omitempty"`
	After        *time.Time `json:"after,omitempty"`
	Before       *time.Time `json:"before,omitempty"`
	Limit        int        `json:"limit,omitempty"`
	Offset       int        `json:"offset,omitempty"`
}

SearchCriteria represents search criteria for keys

type SearchResult

type SearchResult struct {
	Keys       []*Pubkey     `json:"keys"`
	Total      int64         `json:"total"`
	Offset     int           `json:"offset"`
	Limit      int           `json:"limit"`
	HasMore    bool          `json:"has_more"`
	SearchTime time.Duration `json:"search_time"`
}

SearchResult represents search results

type Signature

type Signature struct {
	ScopedDigest string     `json:"scoped_digest"`
	Packet       []byte     `json:"packet"`
	Creation     time.Time  `json:"creation"`
	Expiration   *time.Time `json:"expiration,omitempty"`
	State        int        `json:"state"`
	Ctime        time.Time  `json:"ctime"`
	Mtime        time.Time  `json:"mtime"`
}

Signature represents a signature

type Stats

type Stats struct {
	Total      int64     `json:"total"`
	Inserted   int64     `json:"inserted"`
	Updated    int64     `json:"updated"`
	Ignored    int64     `json:"ignored"`
	Duplicates int64     `json:"duplicates"`
	LastUpdate time.Time `json:"last_update"`
}

Stats represents storage statistics

type Storage

type Storage interface {
	// Key operations
	MatchMD5([]string) ([]string, error)
	ModifiedSince(time.Time) ([]string, error)
	FetchKeys([]string) ([]*Pubkey, error)
	FetchKeysPrefix(string) ([]*Pubkey, error)
	Insert([]*Pubkey) error
	Update(*Pubkey, *Pubkey) error
	Delete([]string) error

	// Statistics
	Stats() (*Stats, error)

	// Health check
	Healthy() error

	// Recon operations
	ReconStats() (*ReconStats, error)
	ReconState() (ReconState, error)

	// Close
	Close() error
}

Storage represents the main storage interface for OpenPGP keys

type StreamingStorage

type StreamingStorage interface {
	StreamKeys(criteria SearchCriteria) (KeyReader, error)
	ImportKeys(reader KeyReader) error
	ExportKeys(criteria SearchCriteria, writer KeyWriter) error
}

StreamingStorage provides streaming capabilities

type SubKey

type SubKey struct {
	RFingerprint string     `json:"rfingerprint"`
	Creation     time.Time  `json:"creation"`
	Expiration   *time.Time `json:"expiration,omitempty"`
	State        int        `json:"state"`
	Packet       []byte     `json:"packet"`
	Ctime        time.Time  `json:"ctime"`
	Mtime        time.Time  `json:"mtime"`
}

SubKey represents a subkey

type Transaction

type Transaction interface {
	// Key operations within transaction
	Insert([]*Pubkey) error
	Update(*Pubkey, *Pubkey) error
	Delete([]string) error

	// Transaction control
	Commit() error
	Rollback() error
}

Transaction represents a storage transaction

type TransactionalStorage

type TransactionalStorage interface {
	Storage
	Begin() (Transaction, error)
}

TransactionalStorage extends Storage with transaction support

type VersionInfo

type VersionInfo struct {
	Version   int64     `json:"version"`
	Timestamp time.Time `json:"timestamp"`
	KeyID     string    `json:"key_id,omitempty"`
	Operation string    `json:"operation"`
	Size      int64     `json:"size"`
	Checksum  string    `json:"checksum"`
}

VersionInfo represents version information

type VersionedStorage

type VersionedStorage interface {
	Storage
	GetVersion() int64
	ListVersions() ([]VersionInfo, error)
	GetKeyVersion(keyID string, version int64) (*Pubkey, error)
	GetKeyHistory(keyID string) ([]VersionInfo, error)
}

VersionedStorage provides versioning capabilities

type WriteOnlyStorage

type WriteOnlyStorage interface {
	// Write operations only
	Insert([]*Pubkey) error
	Update(*Pubkey, *Pubkey) error
	Delete([]string) error
	Close() error
}

WriteOnlyStorage provides write-only access

Jump to

Keyboard shortcuts

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