discovery: Add timestamp to discovery.Update.
The syncbase discovery service needs to be able to order updates from
global discovery and neighborhood discovery based on timestamps in the
case of a changed advertisement.
This change exposes timestamps from discovery.Update.
MultiPart: 1/5
Change-Id: I531c11f2bda5a374fc1db49a973b357e0b11e78b
diff --git a/discovery/.api b/discovery/.api
index a66eefe..4b9ef2e 100644
--- a/discovery/.api
+++ b/discovery/.api
@@ -29,7 +29,7 @@
pkg discovery, type T interface { Advertise, Scan }
pkg discovery, type T interface, Advertise(*context.T, *Advertisement, []security.BlessingPattern) (<-chan struct{}, error)
pkg discovery, type T interface, Scan(*context.T, string) (<-chan Update, error)
-pkg discovery, type Update interface { Addresses, Advertisement, Attachment, Attribute, Id, InterfaceName, IsLost }
+pkg discovery, type Update interface { Addresses, Advertisement, Attachment, Attribute, Id, InterfaceName, IsLost, Timestamp }
pkg discovery, type Update interface, Addresses() []string
pkg discovery, type Update interface, Advertisement() Advertisement
pkg discovery, type Update interface, Attachment(*context.T, string) <-chan DataOrError
@@ -37,3 +37,4 @@
pkg discovery, type Update interface, Id() AdId
pkg discovery, type Update interface, InterfaceName() string
pkg discovery, type Update interface, IsLost() bool
+pkg discovery, type Update interface, Timestamp() time.Time
diff --git a/discovery/update.go b/discovery/update.go
index d2a9fa2..a72a6c1 100644
--- a/discovery/update.go
+++ b/discovery/update.go
@@ -4,7 +4,11 @@
package discovery
-import "v.io/v23/context"
+import (
+ "time"
+
+ "v.io/v23/context"
+)
// Update is the interface for a discovery update.
type Update interface {
@@ -40,6 +44,10 @@
//
// The returned advertisement may not include all attachments.
Advertisement() Advertisement
+
+ // Timestamp returns the time when advertising began for the corresponding
+ // Advertisement.
+ Timestamp() time.Time
}
// DataOrError contains either an attachment data or an error