Add duration method to killable statements

This commit is contained in:
Tobie Morgan Hitchcock 2017-04-28 17:12:11 +01:00
parent b60c663fdd
commit 4c16dafcf3
3 changed files with 26 additions and 1 deletions

View file

@ -45,6 +45,7 @@ type AuthableStatement interface {
type KillableStatement interface { type KillableStatement interface {
Begin() Begin()
Cease() Cease()
Duration() time.Duration
Timedout() <-chan struct{} Timedout() <-chan struct{}
} }
@ -395,7 +396,7 @@ type DefineViewStatement struct {
DB string `cork:"-" codec:"-"` DB string `cork:"-" codec:"-"`
Name *Ident `cork:"name" codec:"name"` Name *Ident `cork:"name" codec:"name"`
Expr Fields `cork:"expr" codec:"expr"` Expr Fields `cork:"expr" codec:"expr"`
What Exprs `cork:"what" codec:"what"` What Tables `cork:"what" codec:"what"`
Cond Expr `cork:"cond" codec:"cond"` Cond Expr `cork:"cond" codec:"cond"`
Group Groups `cork:"group" codec:"group"` Group Groups `cork:"group" codec:"group"`
} }

View file

@ -48,6 +48,10 @@ func (s *SelectStatement) Cease() {
} }
} }
func (s *SelectStatement) Duration() time.Duration {
return s.Timeout
}
func (s *SelectStatement) Timedout() <-chan struct{} { func (s *SelectStatement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil
@ -84,6 +88,10 @@ func (s *CreateStatement) Cease() {
} }
} }
func (s *CreateStatement) Duration() time.Duration {
return s.Timeout
}
func (s *CreateStatement) Timedout() <-chan struct{} { func (s *CreateStatement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil
@ -120,6 +128,10 @@ func (s *UpdateStatement) Cease() {
} }
} }
func (s *UpdateStatement) Duration() time.Duration {
return s.Timeout
}
func (s *UpdateStatement) Timedout() <-chan struct{} { func (s *UpdateStatement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil
@ -156,6 +168,10 @@ func (s *DeleteStatement) Cease() {
} }
} }
func (s *DeleteStatement) Duration() time.Duration {
return s.Timeout
}
func (s *DeleteStatement) Timedout() <-chan struct{} { func (s *DeleteStatement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil
@ -192,6 +208,10 @@ func (s *RelateStatement) Cease() {
} }
} }
func (s *RelateStatement) Duration() time.Duration {
return s.Timeout
}
func (s *RelateStatement) Timedout() <-chan struct{} { func (s *RelateStatement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil

View file

@ -46,6 +46,10 @@ func (s *{{$k.name}}Statement) Cease() {
} }
} }
func (s *{{$k.name}}Statement) Duration() time.Duration {
return s.Timeout
}
func (s *{{$k.name}}Statement) Timedout() <-chan struct{} { func (s *{{$k.name}}Statement) Timedout() <-chan struct{} {
if s.Timeout == 0 { if s.Timeout == 0 {
return nil return nil