本文整理匯總了Golang中github.com/telehash/gogotelehash/internal/lob.Packet.TID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Packet.TID方法的具體用法?Golang Packet.TID怎麽用?Golang Packet.TID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/telehash/gogotelehash/internal/lob.Packet
的用法示例。
在下文中一共展示了Packet.TID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deliverPacket
func (m *MockExchange) deliverPacket(pkt *lob.Packet, dst *Pipe) error {
pkt.TID = 0
args := m.Called(pkt)
return args.Error(0)
}
示例2: write
func (c *Channel) write(pkt *lob.Packet, p *Pipe) error {
if pkt.TID == 0 {
pkt.TID = tracer.NewID()
}
if c.broken {
// When a channel is marked as broken the all writes
// must return a BrokenChannelError.
return c.traceWriteError(pkt, p,
&BrokenChannelError{c.hashname, c.typ, c.id})
}
if c.writeDeadlineReached {
// When a channel reached a write deadline then all writes
// must return a ErrTimeout.
return c.traceWriteError(pkt, p,
ErrTimeout)
}
if c.deliveredEnd {
// When a channel sent a packet with the "end" header set
// then all subsequent writes must return io.EOF
return c.traceWriteError(pkt, p,
io.EOF)
}
c.oSeq++
hdr := pkt.Header()
hdr.C, hdr.HasC = c.id, true
if c.reliable {
hdr.Seq, hdr.HasSeq = c.oSeq, true
}
if !c.serverside && c.oSeq == cInitialSeq {
hdr.Type, hdr.HasType = c.typ, true
}
end := hdr.HasEnd && hdr.End
if end {
c.deliveredEnd = true
c.setCloseDeadline()
}
if c.reliable {
if c.oSeq%30 == 0 || hdr.End {
c.applyAckHeaders(pkt)
}
c.writeBuffer[c.oSeq] = &writeBufferEntry{pkt, end, time.Time{}, p}
c.needsResend = false
}
err := c.x.deliverPacket(pkt, p)
if err != nil {
return c.traceWriteError(pkt, p, err)
}
statChannelSndPkt.Add(1)
if pkt.Header().HasAck {
statChannelSndAckInline.Add(1)
}
if c.oSeq == cInitialSeq && c.serverside {
c.unsetOpenDeadline()
}
c.traceWrite(pkt, p)
if !c.reliable {
pkt.Free()
}
return nil
}