-
Notifications
You must be signed in to change notification settings - Fork 10
/
sys_attachment.go
executable file
·50 lines (44 loc) · 1.07 KB
/
sys_attachment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Code generated by dol build. Only Generate by tools if not existed.
// source: sys_attachment.go
package srv
import (
"context"
"errors"
"time"
"github.com/2637309949/dolphin/packages/xormplus/xorm"
"github.com/2637309949/dolphin/platform/svc"
"github.com/sirupsen/logrus"
)
type SysAttachment struct {
svc.Svc
}
func NewSysAttachment() *SysAttachment {
return &SysAttachment{}
}
// TODO defined srv
func (srv *SysAttachment) TODO(ctx context.Context, db *xorm.Engine, params struct{}) (interface{}, error) {
cwt, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
chi := func(context.Context) chan interface{} {
chi := make(chan interface{}, 1)
go func() {
time.Sleep(1 * time.Second)
chi <- 100
cancel()
close(chi)
}()
return chi
}(cwt)
for range ticker.C {
select {
case <-cwt.Done():
logrus.Infoln("child process interrupt...")
return <-chi, cwt.Err()
default:
logrus.Infoln("awaiting job...")
}
}
return nil, errors.New("no implementation found")
}