-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducer.go
More file actions
62 lines (43 loc) · 1.05 KB
/
producer.go
File metadata and controls
62 lines (43 loc) · 1.05 KB
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
package main
import (
"net/rpc"
"fmt"
"log"
//"bufio"
//"os"
//"strings"
"math/rand"
"time"
)
const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
var seededRand *rand.Rand = rand.New(
rand.NewSource(time.Now().UnixNano()))
func StringWithCharset(length int, charset string) string {
b := make([]byte, length)
for i := range b {
b[i] = charset[seededRand.Intn(len(charset))]
}
return string(b)
}
func String(length int) string {
return StringWithCharset(length, charset)
}
func main() {
client, err := rpc.Dial("tcp", ADDRESS + ":" + PORT)
if err != nil {
log.Fatal("dialing:", err)
}
for{
var reply int
text := String(15)
msgCall := client.Go(QUEUE_NAME + ".PushMessage", text, &reply, nil)
replyCall := <-msgCall.Done // will be equal to divCall
if(replyCall.Error != nil){
fmt.Printf("Error: %d\n", replyCall.Error.Error())
}else{
// no error
fmt.Printf("Result: %d\n", reply)
}
time.Sleep(TIME_FOR_SEND * time.Second)
}
}