Documentation
¶
Index ¶
- Variables
- func MergeSchemas(current, sheet []string) []string
- func ValidateQuery(query Query) error
- type Adapter
- type Cache
- func (c *Cache) Append(record *Record) error
- func (c *Cache) Clear()
- func (c *Cache) ClearDirty()
- func (c *Cache) Delete(key int) error
- func (c *Cache) Get(key int) (*Record, error)
- func (c *Cache) GetAllRecords() []*Record
- func (c *Cache) GetDirtyKeys() []int
- func (c *Cache) GetSchema() []string
- func (c *Cache) Load(records []*Record, schema []string)
- func (c *Cache) Query(query Query) ([]*Record, error)
- func (c *Cache) Set(key int, record *Record) error
- func (c *Cache) SetSchema(schema []string)
- func (c *Cache) Size() int
- func (c *Cache) Update(key int, updates map[string]interface{}) error
- type Client
- func (c *Client) Append(record *Record) error
- func (c *Client) Close() error
- func (c *Client) Delete(key int) error
- func (c *Client) Get(key int) (*Record, error)
- func (c *Client) Initialize(ctx context.Context) error
- func (c *Client) Query(query Query) ([]*Record, error)
- func (c *Client) Set(key int, record *Record) error
- func (c *Client) Sync() error
- func (c *Client) Update(key int, updates map[string]interface{}) error
- type Condition
- type Config
- type Operation
- type OperationType
- type Query
- type Record
- func (r *Record) GetAsBool(col string, defaultValue bool) bool
- func (r *Record) GetAsFloat64(col string, defaultValue float64) float64
- func (r *Record) GetAsInt64(col string, defaultValue int64) int64
- func (r *Record) GetAsString(col string, defaultValue string) string
- func (r *Record) GetAsStrings(col string, defaultValue []string) []string
- func (r *Record) GetAsTime(col string, defaultValue time.Time) time.Time
- func (r *Record) MatchesQuery(query Query) bool
- func (r *Record) SetBool(col string, value bool)
- func (r *Record) SetFloat64(col string, value float64)
- func (r *Record) SetInt64(col string, value int64)
- func (r *Record) SetString(col string, value string)
- func (r *Record) SetStrings(col string, value []string)
- func (r *Record) SetTime(col string, value time.Time)
- type SyncManager
- type SyncStrategy
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MergeSchemas ¶
MergeSchemas merges current schema with sheet schema preserving order
Types ¶
type Adapter ¶
type Adapter interface {
// Load retrieves all records and schema from the spreadsheet
Load(ctx context.Context) ([]*Record, []string, error)
// Save replaces all data in the spreadsheet with the provided records
// The strategy parameter determines how deleted records are handled
Save(ctx context.Context, records []*Record, schema []string, strategy SyncStrategy) error
// BatchUpdate performs multiple operations in a single request
BatchUpdate(ctx context.Context, operations []Operation) error
}
Adapter interface defines methods for interacting with different spreadsheet backends
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache manages in-memory storage of records
func (*Cache) GetAllRecords ¶
GetAllRecords returns all records sorted by key
func (*Cache) GetDirtyKeys ¶
GetDirtyKeys returns keys of modified records
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main KVS client
func (*Client) Initialize ¶
Initialize loads initial data from the adapter
type Condition ¶
type Condition struct {
Column string // カラム名
Operator string // 演算子: ==, !=, >, >=, <, <=, in, between
Value interface{} // 比較値(inの場合は[]interface{}, betweenの場合は[2]interface{})
}
Condition represents a single query condition
type Config ¶
type Config struct {
SyncInterval time.Duration // Interval for periodic sync (default: 30s)
MaxRetries int // Maximum number of retries for API calls (default: 3)
RetryInterval time.Duration // Base interval between retries for exponential backoff (default: 1s)
}
Config represents configuration for the KVS client
type Operation ¶
type Operation struct {
Type OperationType
Record *Record
}
Operation represents a single data operation
type OperationType ¶
type OperationType int
OperationType represents the type of operation
const ( OpAdd OperationType = iota OpUpdate OpDelete )
type Record ¶
type Record struct {
Key int // 行番号 (2から始まる、1行目はカラム定義)
Values map[string]interface{} // カラム名と値のマップ
}
func ApplyQuery ¶
ApplyQuery filters records based on query conditions
func (*Record) GetAsFloat64 ¶
GetAsFloat64 returns the value as float64 or defaultValue if not found
func (*Record) GetAsInt64 ¶
GetAsInt64 returns the value as int64 or defaultValue if not found
func (*Record) GetAsString ¶
GetAsString returns the value as string or defaultValue if not found
func (*Record) GetAsStrings ¶
GetAsStrings returns the value as []string or defaultValue if not found
func (*Record) MatchesQuery ¶
MatchesQuery checks if a record matches all conditions in the query
func (*Record) SetFloat64 ¶
SetFloat64 sets a float64 value
func (*Record) SetStrings ¶
SetStrings sets a []string value (stored as comma-separated string)
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager manages periodic synchronization
func NewSyncManager ¶
func NewSyncManager(client *Client, interval time.Duration) *SyncManager
NewSyncManager creates a new sync manager
func (*SyncManager) Stop ¶
func (sm *SyncManager) Stop()
Stop stops the sync manager and waits for ongoing sync
type SyncStrategy ¶
type SyncStrategy int
SyncStrategy represents the synchronization strategy
const ( // SyncStrategyGapPreserving maintains deleted rows as empty rows to preserve row numbers SyncStrategyGapPreserving SyncStrategy = iota // SyncStrategyCompacting removes deleted rows and compacts the data SyncStrategyCompacting )