watchdog

package
v0.0.0-...-d88ec87 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//Reader turns on reader config generation
	Reader = true
	//Writer turn on writer config generation
	Writer = false
)
View Source
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

View Source
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

type ExecutionDelay struct {
	RequestID string
	Delay     time.Duration
}

ExecutionDelay tells how to change the execution time of a record

type Method

type Method string

Method is the ConsistencyRecord type

const (
	// PUT consistency method states that an object should be present
	PUT Method = "PUT"
	// DELETE consistency method states that an object should be deleted
	DELETE Method = "DELETE"
)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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