1package topology 2 3import "time" 4 5// commandMetadata contains metadata about a command sent to the server. 6type commandMetadata struct { 7 Name string 8 Time time.Time 9 Legacy bool 10 FullCollectionName string 11} 12 13// createMetadata creates metadata for a command. 14func createMetadata(name string, legacy bool, fullCollName string) *commandMetadata { 15 return &commandMetadata{ 16 Name: name, 17 Time: time.Now(), 18 Legacy: legacy, 19 FullCollectionName: fullCollName, 20 } 21} 22 23// TimeDifference returns the difference between now and the time a command was sent in nanoseconds. 24func (cm *commandMetadata) TimeDifference() int64 { 25 t := time.Now() 26 duration := t.Sub(cm.Time) 27 return duration.Nanoseconds() 28} 29