chronos

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Overview

Package chronos provides clock functionality that can be useful when developing and testing Cloud Native Buildpacks.

Below is an example showing how you might use a Clock to measure the duration of an operation:

package main

import (
	"os"

	"github.com/paketo-buildpacks/packit/chronos"
)

func main() {
	duration, err := chronos.DefaultClock.Measure(func() error {
   // Perform some operation, like sleep for 10 seconds
   time.Sleep(10 * time.Second)

   return nil
 })
	if err != nil {
		panic(err)
	}

 fmt.Printf("duration: %s", duration)
	// Output: duration: 10s
}

Index

Constants

This section is empty.

Variables

View Source
var DefaultClock = NewClock(time.Now)

Functions

This section is empty.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

func NewClock

func NewClock(now func() time.Time) Clock

func (Clock) Measure

func (c Clock) Measure(f func() error) (time.Duration, error)

func (Clock) Now

func (c Clock) Now() time.Time

Jump to

Keyboard shortcuts

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