当前位置: 首页>>代码示例>>Golang>>正文


Golang Request.Seq方法代码示例

本文整理汇总了Golang中net/rpc.Request.Seq方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Seq方法的具体用法?Golang Request.Seq怎么用?Golang Request.Seq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net/rpc.Request的用法示例。


在下文中一共展示了Request.Seq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(request *rpc.Request) error {
	name, messageType, seq, err := c.protocol.ReadMessageBegin(c.transport)
	if err != nil {
		return err
	}
	if messageType != MessageTypeCall { // Currently don't support one way
		return errors.New("thrift: expected Call message type")
	}

	// TODO: should use a limited size cache for the nameCache to avoid a possible
	//       memory overflow from nefarious or broken clients
	newName := c.nameCache[name]
	if newName == "" {
		newName = CamelCase(name)
		if !strings.ContainsRune(newName, '.') {
			newName = "Thrift." + newName
		}
		c.nameCache[name] = newName
	}

	c.mu.Lock()
	c.methodName[uint64(seq)] = name
	c.mu.Unlock()

	request.ServiceMethod = newName
	request.Seq = uint64(seq)

	return nil
}
开发者ID:jimmysawczuk,项目名称:go-thrift,代码行数:29,代码来源:server.go

示例2: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	var sz uint16
	err := binary.Read(c.c, binary.BigEndian, &sz)
	if err != nil {
		return err
	}
	log.Print("sz: ", sz)
	raw_message := make([]byte, sz)
	n, err := io.ReadFull(c.c, raw_message)
	if err != nil || n != int(sz) {
		return err
	}
	c.req.reset()
	log.Print("raw_message: ", string(raw_message))
	err = json.Unmarshal(raw_message, &(c.req))
	log.Print("after unmarshal: ", c.req)
	if err != nil {
		log.Print("err: ", err)
		return err
	}
	r.ServiceMethod = c.req.Method
	c.mutex.Lock()
	c.seq++
	c.pending[c.seq] = c.req.Id
	c.req.Id = nil
	r.Seq = c.seq
	c.mutex.Unlock()
	return nil
}
开发者ID:cjl3080434008,项目名称:redis-land-go,代码行数:29,代码来源:custom_jsonrpc.go

示例3: innerReadRequestHeader

func (c *RedisServerCodec) innerReadRequestHeader(r *rpc.Request) (err error) {
	defer func() {
		if ret := recover(); ret != nil {
			err = errors.Errorf("Read Header:%s", ret)
		}
	}()

	m, err := bufioReadMessage(c.r)
	if err != nil {
		return
	}

	arr, err := m.Array()
	if err != nil {
		err = errors.Errorf("must by array type:%v", m.Type)
		return
	}

	op, _ := arr[0].Str()
	op = strings.ToLower(op)
	method, ok := methodMap[op]
	if !ok {
		err = errors.Errorf("method not supported:%s", op)
		return
	}
	r.ServiceMethod = method
	c.seq++
	r.Seq = c.seq
	c.msg = m
	return nil
}
开发者ID:icexin,项目名称:raftkv,代码行数:31,代码来源:redis.go

示例4: Call

func (this *Client) Call(method string, arg interface{}, reply interface{}) (e error) {

	clientConn := new(clientConn)
	clientConn.rest()
	this.codec = NewClientCodec(clientConn)
	req := rpc.Request{}
	req.Seq = defaultIdCreator.NewId()
	req.ServiceMethod = method
	e = this.codec.WriteRequest(&req, arg)
	buffer := bytes.NewBuffer(clientConn.Data)
	resp, e := http.Post(this.addr, "application/json", buffer)
	if e != nil {
		return
	}
	clientConn.SetResponse(resp)
	tmp := &rpc.Response{}
	e = this.codec.ReadResponseHeader(tmp)
	if e != nil {
		return
	}
	e = this.codec.ReadResponseBody(reply)
	if e != nil {
		return
	}
	fmt.Println(string(clientConn.Data))
	return
}
开发者ID:juxuny,项目名称:go,代码行数:27,代码来源:Client.go

示例5: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	var req protorpcpb.Request
	if err := readFrame(c.rwc, &req); err != nil {
		return err
	}
	r.ServiceMethod = req.GetMethod()
	r.Seq = req.GetSeq()
	return nil
}
开发者ID:ironzhang,项目名称:golang,代码行数:9,代码来源:server.go

示例6: writeRequest

func writeRequest(c *clientCodec) error {
	head := rpc.Request{}
	head.ServiceMethod = "TestFunc"
	head.Seq = 1

	body := testpb.Request{}
	body.Query = proto.String("ping www.tencent.com")
	return c.WriteRequest(&head, &body)
}
开发者ID:ironzhang,项目名称:golang,代码行数:9,代码来源:codec_test.go

示例7: ReadRequestHeader

func (c *codec) ReadRequestHeader(r *rpc.Request) error {
	c.header = internal.Header{} // reset
	if err := c.decode(&c.header); err != nil {
		return err
	}

	r.ServiceMethod = c.header.Method
	r.Seq = c.header.SeqID
	return nil
}
开发者ID:pascaldekloe,项目名称:colfer,代码行数:10,代码来源:rpc.go

示例8: ReadRequestHeader

// ReadRequestHeader receives and decodes a net/rpc request header r.
func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	// This is almost identical to ReadResponseHeader(), above.
	var err error
	var hdr ProtoRPCRequestHeader
	if err = c.m.ReadMessage(&hdr); err != nil {
		// Don't log an error here, since this is where normal EOF
		// happens over net/rpc channels, e.g., if a client finishes and
		// disconnects.
		return err
	}
	r.Seq = *hdr.Seq
	r.ServiceMethod = *hdr.Op
	return nil
}
开发者ID:William-J-Earl,项目名称:cloudproxy,代码行数:15,代码来源:protorpc.go

示例9: ReadRequestHeader

// ReadRequestHeader reads the header protobuf (which is prefixed by a uvarint
// indicating its size) from the connection, decodes it, and stores the fields
// in the given request.
func (s *ServerCodec) ReadRequestHeader(req *rpc.Request) error {
	var header wire.Header
	if err := ReadProto(s.r, &header); err != nil {
		return err
	}
	if header.Method == nil {
		return fmt.Errorf("header missing method: %s", header)
	}
	if header.Seq == nil {
		return fmt.Errorf("header missing seq: %s", header)
	}
	req.ServiceMethod = *header.Method
	req.Seq = *header.Seq
	return nil
}
开发者ID:pguelpa,项目名称:go-rpcgen,代码行数:18,代码来源:codec.go

示例10: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	msg := <-c.msgs
	c.req.reset()
	if err := json.Unmarshal(msg.Body, &c.req); err != nil {
		return err
	}
	r.ServiceMethod = c.req.Method
	c.Lock()
	c.seq++
	c.pending[c.seq] = prop{msg.CorrelationId, msg.ReplyTo}
	r.Seq = c.seq
	c.Unlock()

	return nil
}
开发者ID:pakudayo,项目名称:mqrpc,代码行数:15,代码来源:server.go

示例11: ReadRequestHeader

func (this *ServerCodec) ReadRequestHeader(r *rpc.Request) (e error) {
	data, e := ioutil.ReadAll(this.conn)
	if e != nil {
		log.Println(e.Error())
		return
	}
	e = json.Unmarshal(data, &this.req)
	if e != nil {
		this.resp.Error = e.Error()
		return
	}
	r.Seq = this.req.Id
	r.ServiceMethod = this.req.Method
	log.Println("req:", string(*this.req.Params))
	return
}
开发者ID:juxuny,项目名称:go,代码行数:16,代码来源:ServerCodec.go

示例12: ReadRequestHeader

func (server *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	server.curDelivery = <-server.message

	if server.curDelivery.CorrelationId == "" {
		return errors.New("no routing key in delivery")
	}

	r.Seq = atomic.AddUint64(&server.seq, 1)

	server.lock.Lock()
	server.calls[r.Seq] = route{server.curDelivery.MessageId, server.curDelivery.CorrelationId}
	server.lock.Unlock()

	r.ServiceMethod = server.curDelivery.ReplyTo

	return nil
}
开发者ID:vibhavp,项目名称:amqp-rpc,代码行数:17,代码来源:server.go

示例13: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	header := wire.RequestHeader{}
	err := readRequestHeader(c.r, &header)
	if err != nil {
		return err
	}

	c.mutex.Lock()
	c.seq++
	c.pending[c.seq] = header.GetId()
	r.ServiceMethod = header.GetMethod()
	r.Seq = c.seq
	c.mutex.Unlock()

	c.reqHeader = header
	return nil
}
开发者ID:jimmyyan,项目名称:protorpc,代码行数:17,代码来源:server.go

示例14: TestRW

func TestRW(t *testing.T) {
	var buf bufc

	var c codec
	c.w = &buf
	var req rpc.Request
	req.Seq = 1
	req.ServiceMethod = "foo"

	c.WriteRequest(&req, nil)
	c.r = bufio.NewReader(&buf)
	c.ReadRequestHeader(&req)

	if req.Seq != 1 || req.ServiceMethod != "foo" {
		t.Errorf("Request decode/encode mismatch")
	}

}
开发者ID:petemoore,项目名称:rpc4,代码行数:18,代码来源:codec_test.go

示例15: ReadRequestHeader

func (c *serverCodec) ReadRequestHeader(r *rpc.Request) error {
	c.req.Reset()
	packer, err := readPack(c.r, &c.req)
	if err != nil {
		return err
	}

	c.packer = packer
	r.ServiceMethod = c.req.Method
	c.mutex.Lock()
	c.seq++
	c.pending[c.seq] = c.req.Id
	c.req.Id = 0
	r.Seq = c.seq
	c.mutex.Unlock()

	return nil
}
开发者ID:chinaweilu,项目名称:yar-go,代码行数:18,代码来源:server.go


注:本文中的net/rpc.Request.Seq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。