-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcall.go
37 lines (30 loc) · 773 Bytes
/
call.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
package go_remote
import (
"context"
"encoding/json"
"errors"
"strings"
)
// callData stores information about the remote call
type callData []*callInfo
type callInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Args []json.RawMessage `json:"args"`
dependencies *dependencyStore
ctx context.Context
service string
method string
}
func (c *callInfo) parse() {
parts := strings.Split(c.Name, ".")
c.service = parts[0]
c.method = parts[1]
}
// readArgument fills the request object for the RPC method.
func (c *callInfo) readArgument(index int, args interface{}) error {
if index >= len(c.Args) {
return errors.New("Invalid number of parameters")
}
return json.Unmarshal(c.Args[index], args)
}