Documentation
¶
Index ¶
- type Factory
- type Listener
- type Strategy
- func (s *Strategy) Create(ctx context.Context, object types.Object) (types.Object, 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) 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) 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
func (*Factory) Close ¶
func (f *Factory) Close()
Close releases the change listener's connection. The pool is shared with every strategy this factory built and is closed by Strategy.Destroy.
func (*Factory) NewDBStrategy ¶
func (*Factory) Refresh ¶
func (f *Factory) Refresh()
Refresh wakes every watch in this process so that each one lists again. Call it when the process is promoted to leader. As a standby its watches were waiting on notifications, and if a peer was not sending them, for instance during a rolling upgrade, the cache behind those watches can be up to a poll interval behind. A leader should not start acting on that. Without a listener there is nothing to do, because the watches are already on the short poll.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener carries change notifications between processes over a Postgres LISTEN/NOTIFY channel.
Every write announces its table on statements.NotifyChannel from inside the writing transaction. One connection per process listens on that channel and calls the broadcast function each Strategy registered, which is the same wake up the in process write path uses, so a process hears about another process's write as soon as it commits rather than at its next poll.
The connection cannot come from the database/sql pool, because a pooled connection cannot stay blocked waiting for a notification.
func NewListener ¶
NewListener returns a listener for dsn. It does nothing until Start is called.
func (*Listener) Close ¶
func (l *Listener) Close()
Close stops the listener and waits for its connection to be released.
func (*Listener) Connected ¶
Connected reports whether notifications are being delivered. When they are not, polling is a watch's only way to see another process's writes.
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, sqlDB *sql.DB, gvk schema.GroupVersionKind, scheme *runtime.Scheme, tableName string, postgres bool, listener *Listener) (*Strategy, error)
New builds the strategy for one table.
postgres selects the Postgres statements. It is passed in rather than inferred from the pool, because a Postgres pool may hold one connection and then looks like sqlite.
A non-nil listener makes writes to this table announce themselves to other processes and makes this process act on theirs. sqlite passes nil.
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
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package glogrus provides a gorm logger that wraps a logrus.Logger.
|
Package glogrus provides a gorm logger that wraps a logrus.Logger. |