ha

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

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