Documentation ¶
Index ¶
- func Calling1[T any](f func(arg T) error, arg T) func() error
- func Calling1V[T any](f func(arg T), arg T) func() error
- func Calling2[T, U any](f func(arg1 T, arg2 U) error, arg1 T, arg2 U) func() error
- func Calling2V[T, U any](f func(arg1 T, arg2 U), arg1 T, arg2 U) func() error
- func Calling3[T, U, V any](f func(arg1 T, arg2 U, arg3 V) error, arg1 T, arg2 U, arg3 V) func() error
- func Calling3V[T, U, V any](f func(arg1 T, arg2 U, arg3 V), arg1 T, arg2 U, arg3 V) func() error
- func CallingV(f func()) func() error
- func ClosingWith[T io.Closer](f *Finalizer, o T) T
- func FinalizeException(err error) bool
- type Finalizable
- type FinalizationError
- type Finalizer
- func (f *Finalizer) BindToReader(r io.ReadCloser, msg ...string) io.ReadCloser
- func (f *Finalizer) CatchException(matchers ...exception.Matcher) *Finalizer
- func (f *Finalizer) Close(c io.Closer, msg ...string) *Finalizer
- func (f *Finalizer) Finalize() (err error)
- func (f *Finalizer) FinalizeWithErrorPropagation(efferr *error)
- func (f *Finalizer) FinalizeWithErrorPropagationf(efferr *error, msg string, args ...interface{})
- func (f *Finalizer) Include(fi *Finalizer) *Finalizer
- func (f *Finalizer) Length() int
- func (f *Finalizer) Lock(locker sync.Locker, msg ...string) *Finalizer
- func (f *Finalizer) Nested() *Finalizer
- func (f *Finalizer) New() *Finalizer
- func (f *Finalizer) ThrowFinalize()
- func (f *Finalizer) With(fi func() error, msg ...string) *Finalizer
- func (f *Finalizer) WithVoid(fi func(), msg ...string) *Finalizer
- type NumberRange
- type ObjectIdentity
- type RecorderProvider
- type RuntimeFinalizationRecoder
- type RuntimeFinalizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Calling1 ¶
Calling1 can be used with Finalizer.With, to call an error providing function with one argument.
func Calling1V ¶
Calling1V can be used with Finalizer.With, to call a void function with one argument.
func ClosingWith ¶
ClosingWith can be used add a close request to finalizer in a chained call. Unfortunately it is not possible in Go to define parameterized methods, therefore we cannot directly add this function to the Finalizer type.
func FinalizeException ¶
FinalizeException is an exception matcher for nested finalization exceptions.
Types ¶
type Finalizable ¶
type Finalizable interface {
Finalize() error
}
type FinalizationError ¶
type FinalizationError struct {
// contains filtered or unexported fields
}
func (FinalizationError) Unwrap ¶
func (e FinalizationError) Unwrap() error
type Finalizer ¶
type Finalizer struct {
// contains filtered or unexported fields
}
Finalizer gathers finalization functions and calls them by calling the Finalize method(s). Add and Finalize may be called in any sequence and number. Finalize just calls the aggregated functions between its last and the actual call. This way it can be used together with defer to clean up stuff when leaving a function and combine it with controlled intermediate cleanup needed, for example as part of a loop block.
func (*Finalizer) BindToReader ¶
func (f *Finalizer) BindToReader(r io.ReadCloser, msg ...string) io.ReadCloser
BindToReader moves the pending finalizations to the close action of a reader closer.
func (*Finalizer) CatchException ¶
CatchException marks the finalizer to catch exceptions. This must be combined with error propagating defers.
func (*Finalizer) Close ¶
Close will finalize the given object by calling its Close function when the finalizer is finalized.
func (*Finalizer) Finalize ¶
Finalize calls all finalizations in the reverse order of their registration and incorporates catched exceptions.
func (*Finalizer) FinalizeWithErrorPropagation ¶
FinalizeWithErrorPropagation calls all finalizations in the reverse order of their registration and propagates a potential error to the given error variable incorporating an already existing error. This is especially intended to be used in a deferred mode to adapt the error code of a function to incorporate finalization errors.
func (*Finalizer) FinalizeWithErrorPropagationf ¶
FinalizeWithErrorPropagationf calls all finalizations in the reverse order of their registration and propagates a potential error to the given error variable incorporating an already existing error. This is especially intended to be used in a deferred mode to adapt the error code of a function to incorporate finalization errors. The final error will be wrapped by the given common context.
func (*Finalizer) Nested ¶
Nested returns a linked finalizer usable in a nested block, which can be separately finalized. It is intended for sequential use, for example in a for loop. Successive calls will provide the same finalizer. The nested finalizer SHOULD be finalized at the end of its scope before it is requested, again, for the next nested usage.
func (*Finalizer) ThrowFinalize ¶
func (f *Finalizer) ThrowFinalize()
ThrowFinalize executes the finalization and in case of an error it throws the error to be catched by an outer finalize or other error handling with the exception package. It is explicitly useful fo finalize nested finalizers in loops.
type NumberRange ¶
type NumberRange struct {
// contains filtered or unexported fields
}
NumberRange can be used as source for successive id numbers to tag elements, since debuggers not always sow object addresses.
func (*NumberRange) NextId ¶
func (n *NumberRange) NextId() uint64
type ObjectIdentity ¶
type ObjectIdentity string
func NewObjectIdentity ¶
func NewObjectIdentity(kind string) ObjectIdentity
func (ObjectIdentity) String ¶
func (i ObjectIdentity) String() string
type RecorderProvider ¶
type RecorderProvider interface {
GetRecorder() *RuntimeFinalizationRecoder
}
type RuntimeFinalizationRecoder ¶
type RuntimeFinalizationRecoder struct {
// contains filtered or unexported fields
}
func GetRuntimeFinalizationRecorder ¶
func GetRuntimeFinalizationRecorder(o any) *RuntimeFinalizationRecoder
func (*RuntimeFinalizationRecoder) Get ¶
func (r *RuntimeFinalizationRecoder) Get() []ObjectIdentity
func (*RuntimeFinalizationRecoder) IsFinalized ¶
func (r *RuntimeFinalizationRecoder) IsFinalized(objs ...ObjectIdentity) bool
func (*RuntimeFinalizationRecoder) Record ¶
func (r *RuntimeFinalizationRecoder) Record(id ObjectIdentity)
type RuntimeFinalizer ¶
type RuntimeFinalizer struct {
// contains filtered or unexported fields
}
func NewRuntimeFinalizer ¶
func NewRuntimeFinalizer(id ObjectIdentity, r *RuntimeFinalizationRecoder) *RuntimeFinalizer