Documentation
¶
Index ¶
- Constants
- func ContextWithPartitionID(ctx context.Context, partitionID string) context.Context
- func PartitionIDFromContext(ctx context.Context) string
- type Criteria
- type DB
- type Factory
- type FactoryOption
- type GormDB
- func (g *GormDB) Get(ctx context.Context, criteria Criteria) ([]Record, uint, error)
- func (g *GormDB) Insert(ctx context.Context, rec *Record) error
- func (g *GormDB) Start(ctx context.Context) (err error)
- func (g *GormDB) Transaction(ctx context.Context, do func(ctx context.Context) error) error
- func (g *GormDB) Watch(ctx context.Context, criteria WatchCriteria) (chan Record, error)
- type Record
- type Strategy
- func (s *Strategy) Create(ctx context.Context, obj types.Object) (result types.Object, err error)
- func (s *Strategy) Delete(ctx context.Context, obj types.Object) (types.Object, error)
- func (s *Strategy) Destroy()
- func (s *Strategy) Get(ctx context.Context, namespace, name string) (types.Object, error)
- func (s *Strategy) GetToList(ctx context.Context, namespace, name string) (types.ObjectList, error)
- func (s *Strategy) List(ctx context.Context, namespace string, opts storage.ListOptions) (types.ObjectList, error)
- func (s *Strategy) New() types.Object
- func (s *Strategy) NewList() types.ObjectList
- func (s *Strategy) Scheme() *runtime.Scheme
- func (s *Strategy) Start(ctx context.Context)
- func (s *Strategy) Update(ctx context.Context, obj types.Object) (types.Object, error)
- func (s *Strategy) UpdateStatus(ctx context.Context, obj types.Object) (types.Object, error)
- func (s *Strategy) Watch(ctx context.Context, namespace string, opts storage.ListOptions) (<-chan watch.Event, error)
- type TableNamer
- type WatchCriteria
Constants ¶
View Source
const (
OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
)
Variables ¶
This section is empty.
Functions ¶
func ContextWithPartitionID ¶
func PartitionIDFromContext ¶
Types ¶
type Criteria ¶
type Criteria struct {
Name string
Namespace *string
// After is non-inclusive
After uint
// Before is inclusive
Before uint
NoResourceVersion bool
Limit int64
LabelSelector labels.Selector
FieldSelector fields.Selector
IncludeDeleted bool
IncludeGC bool
PartitionID string
// contains filtered or unexported fields
}
type DB ¶
type DB interface {
Transaction(ctx context.Context, do func(ctx context.Context) error) error
Watch(ctx context.Context, criteria WatchCriteria) (chan Record, error)
Get(ctx context.Context, criteria Criteria) ([]Record, uint, error)
Insert(ctx context.Context, rec *Record) error
Start(ctx context.Context) error
}
type Factory ¶
type Factory struct {
DB *gorm.DB
SQLDB *sql.DB
AutoMigrate bool
// contains filtered or unexported fields
}
func NewFactory ¶
func (*Factory) NewDBStrategy ¶
type FactoryOption ¶
type FactoryOption func(*Factory)
func WithMigrationTimeout ¶
func WithMigrationTimeout(timeout time.Duration) FactoryOption
WithMigrationTimeout sets a timeout for the initial database migration if auto migration is enabled.
func WithPartitionIDRequired ¶
func WithPartitionIDRequired() FactoryOption
WithPartitionIDRequired will configure the all DB strategies created from this factory to require a partition ID when querying the database.
type GormDB ¶
type GormDB struct {
// contains filtered or unexported fields
}
func NewDB ¶
func NewDB(tableName string, gvk schema.GroupVersionKind, db *gorm.DB, transformers map[schema.GroupKind]value.Transformer) *GormDB
func (*GormDB) Transaction ¶
type Record ¶
type Record struct {
ID uint
Kind string
Version string
APIGroup string
Name string `gorm:"index:,composite:idx_ns_name_id"`
Namespace string `gorm:"index:,composite:idx_ns_name_id"`
UID string
Generation int
Previous *uint `gorm:"index:,unique"`
Create bool
Created time.Time
Updated time.Time
Deleted *time.Time
Removed *time.Time
Garbage bool `gorm:"index:,composite:idx_garbage;not null;default:0"`
Latest bool `gorm:"index:,composite:idx_latest;default:0"`
Metadata datatypes.JSON
Data datatypes.JSON
Status datatypes.JSON
PartitionID string `gorm:"index:,composite:idx_ns_name_id"`
}
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
func NewStrategy ¶
func (*Strategy) List ¶
func (s *Strategy) List(ctx context.Context, namespace string, opts storage.ListOptions) (types.ObjectList, error)
func (*Strategy) NewList ¶
func (s *Strategy) NewList() types.ObjectList
func (*Strategy) UpdateStatus ¶
type TableNamer ¶
type TableNamer interface {
TableName() string
}
Click to show internal directories.
Click to hide internal directories.