Documentation ¶
Overview ¶
Package neo implements side effects simulation for testing.
Index ¶
- Variables
- type NAT
- type Net
- type NetAddr
- type PacketConn
- func (c *PacketConn) Close() error
- func (c *PacketConn) LocalAddr() net.Addr
- func (c *PacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c *PacketConn) SetDeadline(t time.Time) error
- func (c *PacketConn) SetReadDeadline(t time.Time) error
- func (c *PacketConn) SetWriteDeadline(t time.Time) error
- func (c *PacketConn) WriteTo(p []byte, a net.Addr) (n int, err error)
- type Ticker
- type Time
- func (t *Time) After(d time.Duration) <-chan time.Time
- func (t *Time) Now() time.Time
- func (t *Time) Observe() <-chan struct{}
- func (t *Time) Set(now time.Time)
- func (t *Time) Sleep(d time.Duration)
- func (t *Time) Ticker(d time.Duration) Ticker
- func (t *Time) Timer(d time.Duration) Timer
- func (t *Time) Travel(d time.Duration) time.Time
- func (t *Time) TravelDate(years, months, days int) time.Time
- func (t *Time) When(d time.Duration) time.Time
- type Timer
Constants ¶
This section is empty.
Variables ¶
var ErrDeadline = errors.New("deadline")
Functions ¶
This section is empty.
Types ¶
type NAT ¶
type NAT struct { }
NAT implements facility for Network Address Translation simulation.
Basic example:
[ A ] <-----> [ NAT1 ] <-----> [ NAT2 ] <-----> [ B ] IPa IPa' IPb' IPb 1) A sends packet P with dst = IPb' 2) NAT1 receives packet P and changes it's src to IPa', sending it to NAT2 from IPa'. 3) NAT2 receives packet P from IPa' to IPb', does a lookup to NAT translation table and finds association IPb' <-> IPb. Then it sends packet P to B. 4) B receives packet P from NAT2, observing that it has src = IPa'. Now B can repeat steps 1-4 and send packet back. IPa = 10.5.0.1:30000 IPa' = 83.30.100.1:23100 IPb' = 91.10.100.1:13000 IPb = 10.1.0.1:20000
type Net ¶
type Net struct {
// contains filtered or unexported fields
}
Net is virtual "net" package, implements mesh of peers.
func (*Net) ListenPacket ¶
func (n *Net) ListenPacket(network, address string) (net.PacketConn, error)
ListenPacket announces on the local network address.
type PacketConn ¶
type PacketConn struct {
// contains filtered or unexported fields
}
PacketConn simulates mesh peer of Net.
func (*PacketConn) LocalAddr ¶
func (c *PacketConn) LocalAddr() net.Addr
func (*PacketConn) ReadFrom ¶
ReadFrom reads a packet from the connection, copying the payload into p.
func (*PacketConn) SetDeadline ¶
func (c *PacketConn) SetDeadline(t time.Time) error
func (*PacketConn) SetReadDeadline ¶
func (c *PacketConn) SetReadDeadline(t time.Time) error
func (*PacketConn) SetWriteDeadline ¶
func (c *PacketConn) SetWriteDeadline(t time.Time) error
type Ticker ¶ added in v0.1.2
Ticker abstracts a channel that delivers “ticks” of a clock at intervals.
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time simulates temporal interactions.
All methods are goroutine-safe.
func (*Time) After ¶
After returns new channel that will receive time.Time value with current tme after specified duration.
func (*Time) Observe ¶ added in v0.1.1
func (t *Time) Observe() <-chan struct{}
Observe return channel that closes on clock calls. The current implementation also closes the channel on Ticker’s ticks.
func (*Time) Travel ¶
Travel adds duration to current time and returns result.
Also triggers temporal effects.
func (*Time) TravelDate ¶
TravelDate applies AddDate to current time and returns result.
Also triggers temporal effects.