當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.Call方法代碼示例

本文整理匯總了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
}
開發者ID:datatonic,項目名稱:Dominator,代碼行數:34,代碼來源:poll.go

示例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
}
開發者ID:keep94,項目名稱:Dominator,代碼行數:16,代碼來源:queue.go

示例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
}
開發者ID:keep94,項目名稱:Dominator,代碼行數:20,代碼來源:listImages.go

示例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
}
開發者ID:keep94,項目名稱:Dominator,代碼行數:20,代碼來源:listDirectories.go

示例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)
}
開發者ID:datatonic,項目名稱:Dominator,代碼行數:21,代碼來源:fetch.go

示例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)
}
開發者ID:datatonic,項目名稱:Dominator,代碼行數:21,代碼來源:addImage.go

示例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
}
開發者ID:keep94,項目名稱:Dominator,代碼行數:21,代碼來源:listUnreferencedObjects.go

示例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
}
開發者ID:keep94,項目名稱:Dominator,代碼行數:24,代碼來源:getFiles.go


注:本文中的github.com/Symantec/Dominator/lib/srpc.Client.Call方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。