Documentation ¶
Overview ¶
Package helpers contains helper functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommaDelimitedOptionalValue ¶
CommaDelimitedOptionalValue takes an array of strings and returns a pointer to a string containing all values concatenated with commas, or nil if the array is empty.
Types ¶
type HTTPResponse ¶
type TaskPoller ¶
type TaskPoller[T HTTPResponse] struct { // contains filtered or unexported fields }
TaskPoller is a helper to poll an API for the status of an asynchronous task. It will call the provided taskFunc to get the latest task status and will continue polling until the task completes (succeeds or fails) or an error occurs.
func NewTaskPoller ¶
func NewTaskPoller[T HTTPResponse](taskID string, taskFunc func() (T, error)) *TaskPoller[T]
NewTaskPoller creates a new TaskPoller. taskID is the ID of the asynchronous task to poll. taskFunc is a function that will be called to get the latest status of the task. It should return a HTTPResponse and an error.
func (*TaskPoller[T]) Err ¶
func (s *TaskPoller[T]) Err() error
Err returns the first error encountered while polling.
func (*TaskPoller[T]) Poll ¶
func (s *TaskPoller[T]) Poll(ctx context.Context) bool
Poll calls taskFunc to get the latest task status. It will continue polling until the task completes (succeeds or fails) or an error occurs. Returns true if polling should continue, false otherwise.
func (*TaskPoller[T]) Resp ¶
func (s *TaskPoller[T]) Resp() T
Resp returns the latest response from calling taskFunc.