Documentation ¶
Index ¶
- Constants
- Variables
- func CreateWatchdogSQLClientProps(watchdogConfig *config.WatchdogConfig, readerConfig bool) map[string]string
- type ConsistencyRecord
- type ConsistencyRecordFactory
- type ConsistencyWatchdog
- type ConsistencyWatchdogFactory
- type DefaultConsistencyRecordFactory
- type DeleteMarker
- type ExecutionDelay
- type Method
- type SQLConsistencyRecord
- type SQLWatchdog
- func (watchdog *SQLWatchdog) Delete(marker *DeleteMarker) error
- func (watchdog *SQLWatchdog) GetVersionHeaderName() string
- func (watchdog *SQLWatchdog) Insert(record *ConsistencyRecord) (*DeleteMarker, error)
- func (watchdog *SQLWatchdog) InsertWithRequestID(requestID string, record *ConsistencyRecord) (*DeleteMarker, error)
- func (watchdog *SQLWatchdog) SupplyRecordWithVersion(record *ConsistencyRecord) error
- func (watchdog *SQLWatchdog) UpdateExecutionDelay(delta *ExecutionDelay) error
- type SQLWatchdogFactory
Constants ¶
const ( //Reader turns on reader config generation Reader = true //Writer turn on writer config generation Writer = false )
const ( // ConsistencyLevel is a constant used to put/get policy consistency level to/from request's context ConsistencyLevel = log.ContextKey("ConsistencyLevel") // ReadRepair is a constant used to put/get policy read repair to/from request's context ReadRepair = log.ContextKey("ReadRepair") //ReadRepairObjectVersion tells that watchdog should insert a read-repair record ReadRepairObjectVersion = log.ContextKey("ReadRepairObjectVersion") //NoErrorsDuringRequest indicates that all of the storages requests were successful NoErrorsDuringRequest = log.ContextKey("NoErrorsDuringProcessing") //MultiPartUpload indicates that the request was a finish multipart upload request and the whole multipart was ok MultiPartUpload = log.ContextKey("MultiPartUpload") )
Variables ¶
var ErrDataBase = errors.New("database error")
ErrDataBase indicates a database errors
Functions ¶
func CreateWatchdogSQLClientProps ¶
func CreateWatchdogSQLClientProps(watchdogConfig *config.WatchdogConfig, readerConfig bool) map[string]string
CreateWatchdogSQLClientProps creates watchdog reader/writer config
Types ¶
type ConsistencyRecord ¶
type ConsistencyRecord struct { RequestID string ExecutionDelay time.Duration ObjectID string Method Method Domain string AccessKey string ObjectVersion int }
ConsistencyRecord describes the state of an object in domain
type ConsistencyRecordFactory ¶
type ConsistencyRecordFactory interface {
CreateRecordFor(request *http.Request) (*ConsistencyRecord, error)
}
ConsistencyRecordFactory creates records from http requests
type ConsistencyWatchdog ¶
type ConsistencyWatchdog interface { Insert(record *ConsistencyRecord) (*DeleteMarker, error) Delete(marker *DeleteMarker) error UpdateExecutionDelay(delta *ExecutionDelay) error SupplyRecordWithVersion(record *ConsistencyRecord) error }
ConsistencyWatchdog manages the ConsistencyRecords and DeleteMarkers
func CreateSQL ¶
func CreateSQL(dialect, connStringFormat string, params []string, watchdogConfig *config.WatchdogConfig) (ConsistencyWatchdog, error)
CreateSQL creates ConsistencyWatchdog and ConsistencyRecordFactory that make use of a SQL database
type ConsistencyWatchdogFactory ¶
type ConsistencyWatchdogFactory interface {
CreateWatchdogInstance(config *config.WatchdogConfig) (ConsistencyWatchdog, error)
}
ConsistencyWatchdogFactory creates ConsistencyWatchdogs
func CreateSQLWatchdogFactory ¶
func CreateSQLWatchdogFactory(dbClientFactory *database.GORMDBClientFactory) ConsistencyWatchdogFactory
CreateSQLWatchdogFactory creates instances of SQLWatchdogFactory
type DefaultConsistencyRecordFactory ¶
type DefaultConsistencyRecordFactory struct { }
DefaultConsistencyRecordFactory is a default implementation of ConsistencyRecordFactory
func (*DefaultConsistencyRecordFactory) CreateRecordFor ¶
func (factory *DefaultConsistencyRecordFactory) CreateRecordFor(request *http.Request) (*ConsistencyRecord, error)
CreateRecordFor creates a ConsistencyRecord from a http request
type DeleteMarker ¶
type DeleteMarker struct {
// contains filtered or unexported fields
}
DeleteMarker indicates which ConsistencyRecords for a given object can be deleted
type ExecutionDelay ¶
ExecutionDelay tells how to change the execution time of a record
type SQLConsistencyRecord ¶
type SQLConsistencyRecord struct { ObjectVersion int `gorm:"column:object_version;default:EXTRACT(EPOCH FROM CURRENT_TIMESTAMP at time zone 'utc') * 10^6"` InsertedAt time.Time `gorm:"column:inserted_at"` UpdatedAt time.Time `gorm:"column:updated_at"` ObjectID string `gorm:"column:object_id"` Method string `gorm:"column:method"` Domain string `gorm:"column:domain"` AccessKey string `gorm:"column:access_key"` ExecutionDelay string `gorm:"column:execution_delay"` RequestID string `gorm:"column:request_id"` Error string `gorm:"column:error"` }
SQLConsistencyRecord is a SQL representation of ConsistencyRecord
func (SQLConsistencyRecord) TableName ¶
func (SQLConsistencyRecord) TableName() string
TableName provides the table name for consistency_record
type SQLWatchdog ¶
type SQLWatchdog struct {
// contains filtered or unexported fields
}
SQLWatchdog is a type of ConsistencyWatchdog that uses a SQL database
func (*SQLWatchdog) Delete ¶
func (watchdog *SQLWatchdog) Delete(marker *DeleteMarker) error
Delete deletes from SQL db
func (*SQLWatchdog) GetVersionHeaderName ¶
func (watchdog *SQLWatchdog) GetVersionHeaderName() string
GetVersionHeaderName returns the name of the HTTP header that should hold to object's verison
func (*SQLWatchdog) Insert ¶
func (watchdog *SQLWatchdog) Insert(record *ConsistencyRecord) (*DeleteMarker, error)
Insert inserts to SQL db
func (*SQLWatchdog) InsertWithRequestID ¶
func (watchdog *SQLWatchdog) InsertWithRequestID(requestID string, record *ConsistencyRecord) (*DeleteMarker, error)
InsertWithRequestID inserts a record with custom ID
func (*SQLWatchdog) SupplyRecordWithVersion ¶
func (watchdog *SQLWatchdog) SupplyRecordWithVersion(record *ConsistencyRecord) error
SupplyRecordWithVersion queries database for NOW and sets it as object's version
func (*SQLWatchdog) UpdateExecutionDelay ¶
func (watchdog *SQLWatchdog) UpdateExecutionDelay(delta *ExecutionDelay) error
UpdateExecutionDelay updates execution time of a record in SQL db
type SQLWatchdogFactory ¶
type SQLWatchdogFactory struct {
// contains filtered or unexported fields
}
SQLWatchdogFactory creates instances of SQLWatchdog
func (*SQLWatchdogFactory) CreateWatchdogInstance ¶
func (factory *SQLWatchdogFactory) CreateWatchdogInstance(config *config.WatchdogConfig) (ConsistencyWatchdog, error)
CreateWatchdogInstance creates instances of SQLWatchdog