forked from postmanlabs/observability-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
34 lines (26 loc) · 1.02 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package learn
import (
"strconv"
"github.com/google/uuid"
"github.com/akitasoftware/akita-libs/akid"
pb "github.com/akitasoftware/akita-ir/go/api_spec"
)
var (
// Namespace for witness IDs generated by CLI observation of TCP packets.
tcpWitnessSpace = uuid.Must(uuid.Parse("e7c24637-ccbd-4f16-9d0d-851d1348ba6b"))
)
// A partial witness is a witness that only includes the argument or response.
// It represents a raw observation from a TCP flow and should be paired up with
// the corresponding observation from the opposite flow in the same TCP stream.
type PartialWitness struct {
Witness *pb.Witness
// Key used to pair this PartialWitness up with its counterpart.
PairKey akid.WitnessID
}
// Generates a v5 UUID as witness ID based on stream ID and seq.
func ToWitnessID(streamID uuid.UUID, seq int) akid.WitnessID {
return akid.NewWitnessID(uuid.NewSHA1(tcpWitnessSpace, []byte(streamID.String()+":"+strconv.Itoa(seq))))
}
func toWitnessID(streamID uuid.UUID, seq int) akid.WitnessID {
return ToWitnessID(streamID, seq)
}