// toBigQueryMessage returns a message to upload to BigQuery.
166679
func (i *MintedTokenInfo) toBigQueryMessage() *bqpb.MachineToken {
	// LUCI_MACHINE_TOKEN is the only supported type currently.
	if i.Request.TokenType != tokenserver.MachineTokenType_LUCI_MACHINE_TOKEN {
		panic("unknown token type")
	}
	return &bqpb.MachineToken{
		// Identifier of the token body.
		Fingerprint: utils.TokenFingerprint(i.Response.GetLuciMachineToken().MachineToken),

		// Information about the token.
		MachineFqdn:        i.TokenBody.MachineFqdn,
		TokenType:          i.Request.TokenType,
		IssuedAt:           &timestamp.Timestamp{Seconds: int64(i.TokenBody.IssuedAt)},
		Expiration:         &timestamp.Timestamp{Seconds: int64(i.TokenBody.IssuedAt + i.TokenBody.Lifetime)},
		CertSerialNumber:   fmt.Sprintf("%d", i.TokenBody.CertSn),
		SignatureAlgorithm: i.Request.SignatureAlgorithm,

		// Information about the CA used to authorize this request.
		CaCommonName: i.CA.CN,
		CaConfigRev:  i.CA.UpdatedRev,

		// Information about the request handler.
		PeerIp:         i.PeerIP.String(),
		ServiceVersion: i.Response.ServiceVersion,
		GaeRequestId:   i.RequestID,
	}
}
1166226
func NewMessageFromBytes(nlb []byte) (*Message, error) {
	nlm := C.nlmsg_alloc_size(C.size_t(len(nlb)))
	if nlm == nil {
		return nil, errors.New("failed to create netlink message")
	}
	nlh := C.nlmsg_hdr(nlm)
	copy((*[1 << 20]byte)(unsafe.Pointer(nlh))[:len(nlb)], nlb)
	return &Message{nlm: nlm}, nil
}
1332460
func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
	var r io.Reader
	messageType, r, err = c.NextReader()
	if err != nil {
		return messageType, nil, err
	}
	p, err = ioutil.ReadAll(r)
	return messageType, p, err
}
1082657
func AddBlockMessage(message Message, newBlk Block) Message {
	message.Msg.Blocks = append(message.Msg.Blocks, newBlk)
	return message
}
1263690
func (bot TgBot) SendMessage(cid int, text string, parsemode *ParseModeT, dwp *bool, rtmid *int, rm *ReplyMarkupInt) ResultWithMessage {
	var pm *string = nil
	if parsemode != nil {
		pmt := parsemode.String()
		pm = &pmt
	}
	payload := QuerySendMessage{cid, text, pm, dwp, rtmid, rm}
	return bot.SendMessageQuery(payload)
}
164766
func (p *TCompactProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error {
	_, err := p.writeByteDirect(COMPACT_PROTOCOL_ID)
	if err != nil {
		return NewTProtocolException(err)
	}
	_, err = p.writeByteDirect((COMPACT_VERSION & COMPACT_VERSION_MASK) | ((byte(typeId) << COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_MASK))
	if err != nil {
		return NewTProtocolException(err)
	}
	_, err = p.writeVarint32(seqid)
	if err != nil {
		return NewTProtocolException(err)
	}
	e := p.WriteString(name)
	return e

}
1140339
func (v *Bonk) GetMessage() (o string) {
	if v != nil && v.Message != nil {
		return *v.Message
	}

	return
}
1166207
func (c *Channel) PutMessage(m *Message) error {
	c.RLock()
	defer c.RUnlock()
	if c.Exiting() {
		return errors.New("exiting")
	}
	err := c.put(m)
	if err != nil {
		return err
	}
	atomic.AddUint64(&c.messageCount, 1)
	return nil
}
585599
func NewSentMessage(params *MessageParams) (*sentMessage, error) {
	const payloadSizeFieldMaxSize = 4
	msg := sentMessage{}
	msg.Raw = make([]byte, 1,
		flagsLength+payloadSizeFieldMaxSize+len(params.Payload)+len(params.Padding)+signatureLength+padSizeLimit)
	msg.Raw[0] = 0 // set all the flags to zero
	msg.addPayloadSizeField(params.Payload)
	msg.Raw = append(msg.Raw, params.Payload...)
	err := msg.appendPadding(params)
	return &msg, err
}
586994
func (s *LogStore) WriteMessage(ctx context.Context, data []byte) error {
	s.Logger.Info("write", zap.String("data", string(data)))
	return nil
}
813684
func (t *Topic) PutMessage(m *Message) error {
	t.RLock()
	defer t.RUnlock()
	if atomic.LoadInt32(&t.exitFlag) == 1 {
		return errors.New("exiting")
	}
	err := t.put(m)
	if err != nil {
		return err
	}
	atomic.AddUint64(&t.messageCount, 1)
	atomic.AddUint64(&t.messageBytes, uint64(len(m.Body)))
	return nil
}
245878
func (p *TJSONProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) {
	p.resetContextStack() // THRIFT-3735
	if isNull, err := p.ParseListBegin(); isNull || err != nil {
		return name, typeId, seqId, err
	}
	version, err := p.ReadI32()
	if err != nil {
		return name, typeId, seqId, err
	}
	if version != THRIFT_JSON_PROTOCOL_VERSION {
		e := fmt.Errorf("Unknown Protocol version %d, expected version %d", version, THRIFT_JSON_PROTOCOL_VERSION)
		return name, typeId, seqId, NewTProtocolExceptionWithType(INVALID_DATA, e)

	}
	if name, err = p.ReadString(); err != nil {
		return name, typeId, seqId, err
	}
	bTypeId, err := p.ReadByte()
	typeId = TMessageType(bTypeId)
	if err != nil {
		return name, typeId, seqId, err
	}
	if seqId, err = p.ReadI32(); err != nil {
		return name, typeId, seqId, err
	}
	return name, typeId, seqId, nil
}
806398
func ParseMessage(data []byte) (Message, error) {
	rv := Message{}
	return rv, rv.UnmarshalBinary(data)
}
93807
func (bot TgBot) ForwardMessageQuery(payload ForwardMessageQuery) ResultWithMessage {
	url := bot.buildPath("forwardMessage")
	hookPayload(&payload, bot.DefaultOptions)
	return bot.genericSendPostData(url, payload)
}
251515
func (e *LoadDataInfo) SetMessage() {
	stmtCtx := e.ctx.GetSessionVars().StmtCtx
	numRecords := stmtCtx.RecordRows()
	numDeletes := 0
	numSkipped := numRecords - stmtCtx.CopiedRows()
	numWarnings := stmtCtx.WarningCount()
	msg := fmt.Sprintf(mysql.MySQLErrName[mysql.ErrLoadInfo], numRecords, numDeletes, numSkipped, numWarnings)
	e.ctx.GetSessionVars().StmtCtx.SetMessage(msg)
}
269697
func messageFromBytes(data []byte) (*message, error) {

	var err error
	var versionData [4]byte
	var typeData [4]byte
	minimumDataSize := 4 + 4
	m := new(message)

	// check if the data is smaller than 36 which is the minimum
	if data == nil {
		return nil, MessageParsingError
	}

	if len(data) < minimumDataSize+1 {
		return nil, MessageParsingError
	}

	version := data[:4]
	typeMsg := data[4:8]
	message := data[8:]

	total := copy(versionData[:], version)
	if total != 4 {
		return nil, MessageParsingError
	}

	total = copy(typeData[:], typeMsg)
	if total != 4 {
		return nil, MessageParsingError
	}

	m.Version = smallendian.FromInt(versionData)
	m.Type = smallendian.FromInt(typeData)
	m.Text = string(message)
	return m, err
}
1318659
func (s *logger) logMessage(depth int, level LogLevelName, description string, keysAndValues ...interface{}) {
	// If there are an odd number of keysAndValue, then there's probably one
	// missing, which means we'd interpret a value as a key, which can be bad for
	// logs-as-data, like metrics on keys or elasticsearch. But, instead of
	// throwing the corrupt data out, serialize it into a string, which both
	// keeps the info, and maintains key-value integrity.
	if len(keysAndValues)%2 == 1 {
		// But, before checking for corrupt keys, remove golog_id, if present, cuz
		// that's an auto-field, so don't let user's missuse of keysAndValues mess up
		// the ID, which they didn't do incorrectly.
		if len(keysAndValues) >= 2 && keysAndValues[0] == "golog_id" {
			keysAndValues = []interface{}{
				"golog_id", keysAndValues[1],
				"corruptFields", flattenKeyValues(keysAndValues[2:]),
			}
		} else {
			keysAndValues = []interface{}{"corruptFields", flattenKeyValues(keysAndValues)}
		}
	}

	// hack in caller stats
	if defaultStackTrace {
		if _, fn, line, ok := runtime.Caller(depth + 1); ok {
			keysAndValues = append(keysAndValues, "file", filepath.Base(fn), "line", strconv.Itoa(line))
		}
	}

	msg := s.formatLogEvent(s.flags, level, description, s.staticArgs, keysAndValues...)
	s.l.Println(msg)
}