Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchStreamOnce ¶ added in v0.12.0
type BatchStreamOnce[T any] struct { // contains filtered or unexported fields }
func (*BatchStreamOnce[T]) OnComplete ¶ added in v0.12.0
func (b *BatchStreamOnce[T]) OnComplete(err error)
func (*BatchStreamOnce[T]) OnNext ¶ added in v0.12.0
func (b *BatchStreamOnce[T]) OnNext(t T) error
type Callback ¶
type Callback[T any] interface { // Complete is invoked when the operation completes successfully with the result 't' of type T. Complete(t T) // CompleteError is invoked when the operation fails, providing an error 'err' indicating the failure reason. CompleteError(err error) }
Callback defines an interface for handling the completion of an asynchronous operation. It allows the caller to notify the system when an operation has completed successfully or when it has failed with an error. The interface provides two methods for handling both success and error cases.
The generic type T represents the result type of the operation, which can vary depending on the specific use case.
Methods:
Complete(t T): This method is called when the asynchronous operation completes successfully. It accepts a result of type T, which is the outcome of the operation.
CompleteError(err error): This method is called when the asynchronous operation fails. It accepts an error, which indicates the reason for the failure.
type Once ¶
type Once[T any] struct { OnComplete func(t T) // Callback function called on successful completion OnCompleteError func(err error) // Callback function called when an error occurs // contains filtered or unexported fields }
func (*Once[T]) Complete ¶
func (c *Once[T]) Complete(t T)
Complete is called to notify that the operation has completed successfully with the result 't'. It ensures that the 'OnComplete' callback is only called once.
func (*Once[T]) CompleteError ¶
CompleteError is called to notify that the operation has failed with an error 'err'. It ensures that the 'OnCompleteError' callback is only called once.
type Stream ¶ added in v0.12.0
type Stream[T any] struct { // contains filtered or unexported fields }
func (*Stream[T]) OnComplete ¶ added in v0.12.0
type StreamCallback ¶ added in v0.12.0
type StreamCallback[T any] interface { // OnNext is called whenever a new data item of type T is received from the stream. // It processes the received data item and returns an error if any issues occur during processing. // This method allows for custom logic to be applied to each individual data item in the stream. OnNext(t T) error // OnComplete is called when the stream has ended, either successfully or due to an error. // The 'err' parameter indicates the status of the stream completion. // If the stream ended successfully, 'err' will be nil. Otherwise, // it will contain the error that caused the stream to terminate. OnComplete(err error) }
func NewBatchStreamOnce ¶ added in v0.12.0
func NewStreamOnce ¶ added in v0.12.0
func NewStreamOnce[T any](callback StreamCallback[T]) StreamCallback[T]
func ReadFromStreamCallback ¶ added in v0.12.0
func ReadFromStreamCallback[T any](ch chan *entities.TWithError[T]) StreamCallback[T]