forked from ergo-services/ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
70 lines (61 loc) · 1.82 KB
/
types.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package ergo
import (
"fmt"
"github.com/halturin/ergo/etf"
"sync"
)
var (
ErrAppAlreadyLoaded = fmt.Errorf("Application is already loaded")
ErrAppAlreadyStarted = fmt.Errorf("Application is already started")
ErrAppUnknown = fmt.Errorf("Unknown application name")
ErrAppIsNotRunning = fmt.Errorf("Application is not running")
ErrProcessBusy = fmt.Errorf("Process is busy")
ErrNameIsTaken = fmt.Errorf("Name is taken")
ErrUnsupportedRequest = fmt.Errorf("Unsupported request")
ErrTimeout = fmt.Errorf("Timed out")
ErrFragmented = fmt.Errorf("Fragmented data")
ErrStop = fmt.Errorf("stop")
)
// Distributed operations codes (http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html)
const (
distProtoLINK = 1
distProtoSEND = 2
distProtoEXIT = 3
distProtoUNLINK = 4
distProtoNODE_LINK = 5
distProtoREG_SEND = 6
distProtoGROUP_LEADER = 7
distProtoEXIT2 = 8
distProtoSEND_TT = 12
distProtoEXIT_TT = 13
distProtoREG_SEND_TT = 16
distProtoEXIT2_TT = 18
distProtoMONITOR = 19
distProtoDEMONITOR = 20
distProtoMONITOR_EXIT = 21
distProtoSEND_SENDER = 22
distProtoSEND_SENDER_TT = 23
distProtoPAYLOAD_EXIT = 24
distProtoPAYLOAD_EXIT_TT = 25
distProtoPAYLOAD_EXIT2 = 26
distProtoPAYLOAD_EXIT2_TT = 27
distProtoPAYLOAD_MONITOR_P_EXIT = 28
)
type peer struct {
name string
send []chan []etf.Term
i int
n int
mutex sync.Mutex
}
func (p *peer) GetChannel() chan []etf.Term {
p.mutex.Lock()
defer p.mutex.Unlock()
c := p.send[p.i]
p.i++
if p.i < p.n {
return c
}
p.i = 0
return c
}