mojo/discovery: Add InstanceName to the mojom file.
Change-Id: If73b1a702c944616f360fb197840bce722c86b00
diff --git a/go/src/mojom/vanadium/discovery/discovery.mojom.go b/go/src/mojom/vanadium/discovery/discovery.mojom.go
index 81f1fc8..0c0393f 100644
--- a/go/src/mojom/vanadium/discovery/discovery.mojom.go
+++ b/go/src/mojom/vanadium/discovery/discovery.mojom.go
@@ -1,6 +1,6 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
// This file is autogenerated by:
// mojo/public/tools/bindings/mojom_bindings_generator.py
@@ -1123,13 +1123,14 @@
type Service struct {
InstanceUuid []uint8
+ InstanceName string
InterfaceName string
Attrs map[string]string
Addrs []string
}
func (s *Service) Encode(encoder *bindings.Encoder) error {
- encoder.StartStruct(32, 0)
+ encoder.StartStruct(40, 0)
if err := encoder.WritePointer(); err != nil {
return err
}
@@ -1145,6 +1146,12 @@
if err := encoder.WritePointer(); err != nil {
return err
}
+ if err := encoder.WriteString(s.InstanceName); err != nil {
+ return err
+ }
+ if err := encoder.WritePointer(); err != nil {
+ return err
+ }
if err := encoder.WriteString(s.InterfaceName); err != nil {
return err
}
@@ -1215,7 +1222,7 @@
}
var service_Versions []bindings.DataHeader = []bindings.DataHeader{
- bindings.DataHeader{40, 0},
+ bindings.DataHeader{48, 0},
}
func (s *Service) Decode(decoder *bindings.Decoder) error {
@@ -1274,6 +1281,21 @@
if err != nil {
return err
}
+ s.InstanceName = value0
+ }
+ }
+ if header.ElementsOrVersion >= 0 {
+ pointer0, err := decoder.ReadPointer()
+ if err != nil {
+ return err
+ }
+ if pointer0 == 0 {
+ return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"}
+ } else {
+ value0, err := decoder.ReadString()
+ if err != nil {
+ return err
+ }
s.InterfaceName = value0
}
}
diff --git a/go/src/vanadium/discovery/internal/discovery.go b/go/src/vanadium/discovery/internal/discovery.go
index 59da5fa..b5a3d58 100644
--- a/go/src/vanadium/discovery/internal/discovery.go
+++ b/go/src/vanadium/discovery/internal/discovery.go
@@ -63,6 +63,7 @@
vService := discovery.Service{
InstanceUuid: s.InstanceUuid,
InterfaceName: s.InterfaceName,
+ InstanceName: s.InstanceName,
Attrs: discovery.Attributes(s.Attrs),
Addrs: s.Addrs,
}
@@ -101,6 +102,7 @@
return mojom.Service{
InstanceUuid: s.InstanceUuid,
InterfaceName: s.InterfaceName,
+ InstanceName: s.InstanceName,
Attrs: s.Attrs,
Addrs: s.Addrs,
}
@@ -137,7 +139,7 @@
// Stop stops the scan.
func (d *DiscoveryService) Stop(handle uint32) error {
- if handle % 2 == 0 {
+ if handle%2 == 0 {
return d.stopScan(handle)
}
return d.stopAdvertising(handle)
diff --git a/go/src/vanadium/discovery/internal/discovery_test.go b/go/src/vanadium/discovery/internal/discovery_test.go
index 585eb48..7cc2dd2 100644
--- a/go/src/vanadium/discovery/internal/discovery_test.go
+++ b/go/src/vanadium/discovery/internal/discovery_test.go
@@ -79,7 +79,8 @@
"key1": "value1",
"key2": "value2",
},
- Addrs: []string{"addr1", "addr2"},
+ InstanceName: "service1",
+ Addrs: []string{"addr1", "addr2"},
}
id, e1, e2 := s.Advertise(testService, nil)
@@ -103,7 +104,8 @@
"key1": "value1",
"key2": "value2",
},
- Addrs: []string{"addr1", "addr2"},
+ InstanceName: "service2",
+ Addrs: []string{"addr1", "addr2"},
}
_, e1, e2 = s.Advertise(testService2, nil)
diff --git a/mojom/vanadium/discovery.mojom b/mojom/vanadium/discovery.mojom
index 1114bfe..884d129 100644
--- a/mojom/vanadium/discovery.mojom
+++ b/mojom/vanadium/discovery.mojom
@@ -9,6 +9,8 @@
// The 128 bit (16 byte) universal unique identifier of a service instance.
// If this is not specified, a random UUID will be used.
array<uint8> InstanceUuid;
+ // Optional name of the service instance.
+ string InstanceName;
// The interface that the service implements.
// E.g., 'v.io/v23/services/vtrace.Store'.
string InterfaceName;