Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailoverHandle ¶
type FailoverHandle[T any] struct { FailOverTime time.Duration // perform failover if current downtime is bigger than this value FailOverOperationCount int // perform failover if Ret method is called certain times // contains filtered or unexported fields }
FailoverHandle provide failover feature for a given resource.
func NewFailoverHandle ¶
func NewFailoverHandle[T any](factory func() (*T, error)) (*FailoverHandle[T], error)
func NewFailoverHandleCloser ¶
func NewFailoverHandleCloser[T any](factory func() (*T, error), close func(t *T)) (*FailoverHandle[T], error)
func (*FailoverHandle[T]) Close ¶
func (n *FailoverHandle[T]) Close() error
Close is used when target object need cleanup.
func (*FailoverHandle[T]) Failover ¶
func (n *FailoverHandle[T]) Failover()
Failover create another target object using a factory method, call close callback passing the old target object if necessary.
func (*FailoverHandle[T]) Get ¶
func (n *FailoverHandle[T]) Get() *T
Get return the target object. User should not copy this value to another variable.
func (*FailoverHandle[T]) Ret ¶
func (n *FailoverHandle[T]) Ret(ok bool)
Ret should be called after any method call on the target object. This is necessary for computing downtime.
Click to show internal directories.
Click to hide internal directories.