本文整理匯總了Golang中github.com/Symantec/Dominator/lib/srpc.Client.Call方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Call方法的具體用法?Golang Client.Call怎麽用?Golang Client.Call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Symantec/Dominator/lib/srpc.Client
的用法示例。
在下文中一共展示了Client.Call方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: callPoll
func callPoll(client *srpc.Client, request sub.PollRequest,
reply *sub.PollResponse) error {
conn, err := client.Call("Subd.Poll")
if err != nil {
return err
}
defer conn.Close()
encoder := gob.NewEncoder(conn)
if err := encoder.Encode(request); err != nil {
return err
}
conn.Flush()
str, err := conn.ReadString('\n')
if err != nil {
return err
}
if str != "\n" {
return errors.New(str)
}
if err := gob.NewDecoder(conn).Decode(reply); err != nil {
return err
}
if reply.FileSystemFollows {
reply.FileSystem, err = filesystem.Decode(conn)
if err != nil {
return err
}
reply.ObjectCache, err = objectcache.Decode(conn)
if err != nil {
return err
}
}
return nil
}
示例2: newObjectAdderQueue
func newObjectAdderQueue(client *srpc.Client) (*ObjectAdderQueue, error) {
var objQ ObjectAdderQueue
var err error
objQ.conn, err = client.Call("ObjectServer.AddObjects")
if err != nil {
return nil, err
}
objQ.encoder = gob.NewEncoder(objQ.conn)
getResponseChan := make(chan bool, 65536)
errorChan := make(chan error, 1024)
objQ.getResponseChan = getResponseChan
objQ.errorChan = errorChan
objQ.sendSemaphore = make(chan bool, 1)
go readResponses(objQ.conn, getResponseChan, errorChan)
return &objQ, nil
}
示例3: listImages
func listImages(client *srpc.Client) ([]string, error) {
conn, err := client.Call("ImageServer.ListImages")
if err != nil {
return nil, err
}
defer conn.Close()
images := make([]string, 0)
for {
line, err := conn.ReadString('\n')
if err != nil {
return nil, err
}
line = line[:len(line)-1]
if line == "" {
break
}
images = append(images, line)
}
return images, nil
}
示例4: listDirectories
func listDirectories(client *srpc.Client) ([]image.Directory, error) {
conn, err := client.Call("ImageServer.ListDirectories")
if err != nil {
return nil, err
}
defer conn.Close()
directories := make([]image.Directory, 0)
decoder := gob.NewDecoder(conn)
for {
var directory image.Directory
if err := decoder.Decode(&directory); err != nil {
return nil, err
}
if directory.Name == "" {
break
}
directories = append(directories, directory)
}
return directories, nil
}
示例5: callFetch
func callFetch(client *srpc.Client, request sub.FetchRequest,
reply *sub.FetchResponse) error {
conn, err := client.Call("Subd.Fetch")
if err != nil {
return err
}
defer conn.Close()
encoder := gob.NewEncoder(conn)
if err := encoder.Encode(request); err != nil {
return err
}
conn.Flush()
str, err := conn.ReadString('\n')
if err != nil {
return err
}
if str != "\n" {
return errors.New(str)
}
return gob.NewDecoder(conn).Decode(reply)
}
示例6: callAddImage
func callAddImage(client *srpc.Client, request imageserver.AddImageRequest,
reply *imageserver.AddImageResponse) error {
conn, err := client.Call("ImageServer.AddImage")
if err != nil {
return err
}
defer conn.Close()
encoder := gob.NewEncoder(conn)
if err := encoder.Encode(request); err != nil {
return err
}
conn.Flush()
str, err := conn.ReadString('\n')
if err != nil {
return err
}
if str != "\n" {
return errors.New(str)
}
return gob.NewDecoder(conn).Decode(reply)
}
示例7: listUnreferencedObjects
func listUnreferencedObjects(client *srpc.Client) (
map[hash.Hash]uint64, error) {
conn, err := client.Call("ImageServer.ListUnreferencedObjects")
if err != nil {
return nil, err
}
defer conn.Close()
objects := make(map[hash.Hash]uint64)
decoder := gob.NewDecoder(conn)
for {
var object imageserver.Object
if err := decoder.Decode(&object); err != nil {
return nil, err
}
if object.Size < 1 {
break
}
objects[object.Hash] = object.Size
}
return objects, nil
}
示例8: getFiles
func getFiles(client *srpc.Client, filenames []string,
readerFunc func(reader io.Reader, size uint64) error) error {
conn, err := client.Call("Subd.GetFiles")
if err != nil {
return err
}
defer conn.Close()
go sendRequests(conn, filenames)
decoder := gob.NewDecoder(conn)
for range filenames {
var reply sub.GetFileResponse
if err := decoder.Decode(&reply); err != nil {
return err
}
if reply.Error != nil {
return reply.Error
}
if err := readerFunc(&io.LimitedReader{R: conn, N: int64(reply.Size)},
reply.Size); err != nil {
return err
}
}
return nil
}