wait

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 2 Imported by: 2

README

Wait

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

A simple library to wait for something.

Prerequisites

  • Go >= 1.17

Install

go get go.nhat.io/wait

Usage

package main

import (
	"context"
	"time"

	"go.nhat.io/wait"
)

func execute(ctx context.Context) error {
	if err := wait.ForDuration(time.Minute).Wait(ctx); err != nil {
        return err
	}

	// Do something here.

	return nil
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this

Documentation

Overview

Package wait provides functionalities for waiting for a condition.

Index

Constants

This section is empty.

Variables

View Source
var NoWait = noWait{}

NoWait is a Waiter that does not wait.

Functions

This section is empty.

Types

type ForDuration

type ForDuration time.Duration

ForDuration is a Waiter that waits for a duration.

func (ForDuration) Wait

func (d ForDuration) Wait(ctx context.Context) error

Wait waits for the duration unless the context is canceled.

type ForSignal

type ForSignal <-chan time.Time

ForSignal is a Waiter that waits for a signal.

func (ForSignal) Wait

func (s ForSignal) Wait(ctx context.Context) error

Wait waits for a signal unless the context is canceled.

type Func

type Func func(ctx context.Context) error

Func is a function that delays the execution.

func (Func) Wait

func (f Func) Wait(ctx context.Context) error

Wait waits for the function to return.

type Until

type Until time.Time

Until is a Waiter that waits until a time.

func (Until) Wait

func (t Until) Wait(ctx context.Context) error

Wait waits until the time unless the context is canceled.

type Waiter

type Waiter interface {
	Wait(ctx context.Context) error
}

Waiter is an interface that waits for a condition.

Directories

Path Synopsis
Package wait provides functionalities for mocking the wait components.
Package wait provides functionalities for mocking the wait components.

Jump to

Keyboard shortcuts

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