Commit 86aa2d19 authored by Geoff Simmons's avatar Geoff Simmons

Rename vsm.AttachTmo() to .Timeout().

parent 19b11ee5
...@@ -329,7 +329,7 @@ func Attach(name string, timeout time.Duration) (*Admin, error) { ...@@ -329,7 +329,7 @@ func Attach(name string, timeout time.Duration) (*Admin, error) {
return nil, errors.New("Cannot initialize for attachment") return nil, errors.New("Cannot initialize for attachment")
} }
defer vsm.Destroy() defer vsm.Destroy()
if err := vsm.AttachTmo(timeout); err != nil { if err := vsm.Timeout(timeout); err != nil {
return nil, err return nil, err
} }
if err := vsm.Attach(name); err != nil { if err := vsm.Attach(name); err != nil {
......
...@@ -155,7 +155,7 @@ func (log *Log) Timeout(tmo time.Duration) error { ...@@ -155,7 +155,7 @@ func (log *Log) Timeout(tmo time.Duration) error {
if err := log.initVSM(); err != nil { if err := log.initVSM(); err != nil {
return err return err
} }
return log.vsm.AttachTmo(tmo) return log.vsm.Timeout(tmo)
} }
// Attach to an instance of Varnish -- varnishd with a running worker // Attach to an instance of Varnish -- varnishd with a running worker
......
...@@ -272,7 +272,7 @@ func (stats *Stats) Timeout(tmo time.Duration) error { ...@@ -272,7 +272,7 @@ func (stats *Stats) Timeout(tmo time.Duration) error {
if err := stats.initVSM(); err != nil { if err := stats.initVSM(); err != nil {
return err return err
} }
return stats.vsm.AttachTmo(tmo) return stats.vsm.Timeout(tmo)
} }
func (stats *Stats) clude(nmGlob string, exclude bool) error { func (stats *Stats) clude(nmGlob string, exclude bool) error {
......
...@@ -100,22 +100,22 @@ func TestAttach(t *testing.T) { ...@@ -100,22 +100,22 @@ func TestAttach(t *testing.T) {
const zerosec = time.Duration(0) const zerosec = time.Duration(0)
func TestAttachTmo(t *testing.T) { func TestTimeout(t *testing.T) {
v := New() v := New()
defer v.Destroy() defer v.Destroy()
for _, s := range []int{0, 1, -1, ^0, int(^uint(0) >> 1)} { for _, s := range []int{0, 1, -1, ^0, int(^uint(0) >> 1)} {
if e := v.AttachTmo(time.Duration(s) * time.Second); e != nil { if e := v.Timeout(time.Duration(s) * time.Second); e != nil {
t.Error("AttachTmo():", e) t.Error("Timeout():", e)
} }
} }
var n *VSM var n *VSM
if err := n.AttachTmo(zerosec); err == nil { if err := n.Timeout(zerosec); err == nil {
t.Error("expected nil.AttachTmo() to fail") t.Error("expected nil.Timeout() to fail")
} }
uninit := new(VSM) uninit := new(VSM)
if err := uninit.AttachTmo(zerosec); err == nil { if err := uninit.Timeout(zerosec); err == nil {
t.Error("expected uninitialized.AttachTmo() to fail") t.Error("expected uninitialized.Timeout() to fail")
} }
} }
...@@ -128,8 +128,8 @@ func TestAttachInstance(t *testing.T) { ...@@ -128,8 +128,8 @@ func TestAttachInstance(t *testing.T) {
f := New() f := New()
defer f.Destroy() defer f.Destroy()
if err := f.AttachTmo(zerosec); err != nil { if err := f.Timeout(zerosec); err != nil {
t.Error("AttachTmo(0s):", err) t.Error("Timeout(0s):", err)
} }
if err := f.Attach("instanceDoesNotExist"); err == nil { if err := f.Attach("instanceDoesNotExist"); err == nil {
t.Error("expected Attach() to fail for a " + t.Error("expected Attach() to fail for a " +
......
...@@ -118,12 +118,12 @@ func (v *VSM) Error() string { ...@@ -118,12 +118,12 @@ func (v *VSM) Error() string {
return C.GoString(C.VSM_Error(v.VSM)) return C.GoString(C.VSM_Error(v.VSM))
} }
// AttachTmo sets the timeout for attaching to a Varnish instance. If // Timeout sets the timeout for attaching to a Varnish instance. If
// the Duration, truncated to seconds, is >= 0s, then wait that many // the Duration, truncated to seconds, is >= 0s, then wait that many
// seconds to attach. If the Duration < 0s, wait indefinitely. By // seconds to attach. If the Duration < 0s, wait indefinitely. By
// default, the Varnish default timeout holds (5s in recent Varnish // default, the Varnish default timeout holds (5s in recent Varnish
// versions). // versions).
func (v *VSM) AttachTmo(tmo time.Duration) error { func (v *VSM) Timeout(tmo time.Duration) error {
if err := v.checkNil(); err != nil { if err := v.checkNil(); err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment