-
Notifications
You must be signed in to change notification settings - Fork 28
/
model.go
51 lines (47 loc) · 2.02 KB
/
model.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// 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.
// Package discovery defines types and interfaces for discovering services.
package discovery
import (
"v.io/v23/context"
"v.io/v23/security"
)
// T is the interface for discovery operations; it is the client side library
// for the discovery service.
type T interface {
// Advertise broadcasts the advertisement to be discovered by "Scan" operations.
//
// visibility is used to limit the principals that can see the advertisement. An
// empty set means that there are no restrictions on visibility (i.e, equivalent
// to []security.BlessingPattern{security.AllPrincipals}).
//
// If the advertisement id is not specified, a random unique a random unique identifier
// will be assigned. The advertisement should not be changed while it is being advertised.
//
// It is an error to have simultaneously active advertisements for two identical
// instances (Advertisement.Id).
//
// Advertising will continue until the context is canceled or exceeds its deadline
// and the returned channel will be closed when it stops.
Advertise(ctx *context.T, ad *Advertisement, visibility []security.BlessingPattern) (<-chan struct{}, error)
// Scan scans advertisements that match the query and returns the channel of updates.
//
// Scan excludes the advertisements that are advertised from the same discovery
// instance.
//
// The query is a WHERE expression of a syncQL query against advertisements, where
// key is Advertisement.Id and value is Advertisement.
//
// Examples
//
// v.InterfaceName = "v.io/i"
// v.InterfaceName = "v.io/i" AND v.Attributes["a"] = "v"
// v.Attributes["a"] = "v1" OR v.Attributes["a"] = "v2"
//
// SyncQL tutorial at:
// https://vanadium.github.io/tutorials/syncbase/syncql-tutorial.html
//
// Scanning will continue until the context is canceled or exceeds its deadline.
Scan(ctx *context.T, query string) (<-chan Update, error)
}