config

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package config provides configuration options for cloudemu services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
	Since(t time.Time) time.Duration
	After(d time.Duration) <-chan time.Time
}

Clock provides time operations, enabling deterministic testing.

type FakeClock

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

FakeClock is a deterministic clock for testing.

func NewFakeClock

func NewFakeClock(t time.Time) *FakeClock

NewFakeClock creates a FakeClock set to the given time.

func (*FakeClock) Advance

func (c *FakeClock) Advance(d time.Duration)

Advance moves the fake clock forward by the given duration.

func (*FakeClock) After

func (c *FakeClock) After(_ time.Duration) <-chan time.Time

After returns a channel that receives the fake time immediately.

func (*FakeClock) Now

func (c *FakeClock) Now() time.Time

Now returns the fake current time.

func (*FakeClock) Set

func (c *FakeClock) Set(t time.Time)

Set sets the fake clock to a specific time.

func (*FakeClock) Since

func (c *FakeClock) Since(t time.Time) time.Duration

Since returns the duration since t based on the fake clock.

type Option

type Option func(*Options)

Option is a functional option for configuring cloudemu services.

func WithAccountID

func WithAccountID(id string) Option

WithAccountID sets the cloud account ID.

func WithClock

func WithClock(c Clock) Option

WithClock sets the clock implementation.

func WithLatency

func WithLatency(d time.Duration) Option

WithLatency sets simulated latency for operations.

func WithProjectID

func WithProjectID(id string) Option

WithProjectID sets the cloud project ID.

func WithRegion

func WithRegion(region string) Option

WithRegion sets the cloud region.

type Options

type Options struct {
	Clock     Clock
	Region    string
	Latency   time.Duration
	AccountID string
	ProjectID string
}

Options holds configuration for cloudemu services.

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions creates Options from the given functional options.

type RealClock

type RealClock struct{}

RealClock uses the real system clock.

func (RealClock) After

func (RealClock) After(d time.Duration) <-chan time.Time

After waits for the duration to elapse and then sends the current time on the returned channel.

func (RealClock) Now

func (RealClock) Now() time.Time

Now returns the current time.

func (RealClock) Since

func (RealClock) Since(t time.Time) time.Duration

Since returns the time elapsed since t.

Jump to

Keyboard shortcuts

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