Ejemplo n.º 1
0
func (p *LogArgs) ReadField1(iprot thrift.TProtocol) (err thrift.TProtocolException) {
	_etype16, _size13, err := iprot.ReadListBegin()
	if err != nil {
		return thrift.NewTProtocolExceptionReadField(-1, "p.Messages", "", err)
	}
	p.Messages = thrift.NewTList(_etype16, _size13)
	for _i17 := 0; _i17 < _size13; _i17++ {
		_elem18 := NewLogEntry()
		err21 := _elem18.Read(iprot)
		if err21 != nil {
			return thrift.NewTProtocolExceptionReadStruct("_elem18LogEntry", err21)
		}
		p.Messages.Push(_elem18)
	}
	err = iprot.ReadListEnd()
	if err != nil {
		return thrift.NewTProtocolExceptionReadField(-1, "", "list", err)
	}
	return err
}
Ejemplo n.º 2
0
// WriteMany sends a batch of multiple message write requests to the scribe node.
func (conn *Conn) WriteMany(msgs ...Message) error {
	tlist := thrift.NewTList(thrift.TypeFromValue(scribe.NewLogEntry()), len(msgs))
	for _, msg := range msgs {
		tlog := scribe.NewLogEntry()
		tlog.Category = msg.Category
		tlog.Message = msg.Payload
		tlist.Push(tlog)
	}

	conn.Lock()
	defer conn.Unlock()

	result, err := conn.client.Log(tlist)
	if err != nil {
		return err
	}
	err = resultCodeToError(result)
	if err != nil {
		return err
	}
	return nil
}