Documentation
¶
Overview ¶
Package dotest runs durable object sessions in memory, for tests: a host's tests of its agent on the durable object runtime, and the runtime's own. Platform stops objects, fires their alarms and fails their reads and writes the way a real platform can, so a test sees what a session does when that happens.
Index ¶
- type Platform
- func (p *Platform) Alarm(id session.ID) time.Time
- func (p *Platform) Evict(id session.ID)
- func (p *Platform) FailReads(id session.ID, fail func(key string) bool)
- func (p *Platform) FailWrites(id session.ID, fail func(ops []durableobject.Op) bool)
- func (p *Platform) FireAlarm(ctx context.Context, id session.ID) error
- func (p *Platform) Idle(ctx context.Context, id session.ID) error
- func (p *Platform) Keys(id session.ID) []string
- func (p *Platform) Object(id session.ID) durableobject.Ref
- func (p *Platform) WaitAlarm(ctx context.Context, id session.ID, after time.Time) (time.Time, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Platform ¶
type Platform struct {
// contains filtered or unexported fields
}
Platform is a durableobject.Platform in memory. Each object's storage outlives the object: after Evict, the next request makes a new object over the same storage, as a platform does.
func New ¶
func New(cfg durableobject.Config) *Platform
New returns an empty Platform whose objects run with cfg.
func NewWire ¶
func NewWire(cfg durableobject.Config) *Platform
NewWire is New, but every call to an object, from a client or from another object, goes over the object protocol (durableobject.Handler and durableobject.Remote), as it does on a platform where objects are remote. Evict also breaks the object's open streams, as a platform that takes an object away does.
func (*Platform) Evict ¶
Evict stops id's object, as a platform that takes it away does: what it still runs can no longer read or write its storage. The next request makes a new object over the same storage.
func (*Platform) FailReads ¶
FailReads makes id's storage fail each read whose key fail reports, as an outage does: a Get's key, or a Scan's prefix. Nil makes every read work again.
func (*Platform) FailWrites ¶
FailWrites makes id's storage fail each write whose ops fail reports, as an outage does; nil makes every write work again.