// 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.

// This file was auto-generated by the vanadium vdl tool.
// Source: types.vdl

package discovery

import (
	// VDL system imports
	"v.io/v23/vdl"
)

// Advertisement represents a feed into advertiser to broadcast its contents
// to scanners.
//
// A large advertisement may require additional RPC calls causing delay in
// discovery. We limit the maximum size of an advertisement to 512 bytes
// excluding id and attachments.
type Advertisement struct {
	// Universal unique identifier of the advertisement.
	// If this is not specified, a random unique identifier will be assigned.
	Id AdId
	// Interface name that the advertised service implements.
	// E.g., 'v.io/v23/services/vtrace.Store'.
	InterfaceName string
	// Addresses (vanadium object names) that the advertised service is served on.
	// E.g., '/host:port/a/b/c', '/ns.dev.v.io:8101/blah/blah'.
	Addresses []string
	// Attributes as a key/value pair.
	// E.g., {'resolution': '1024x768'}.
	//
	// The key must be US-ASCII printable characters, excluding the '=' character
	// and should not start with '_' character.
	Attributes Attributes
	// Attachments as a key/value pair.
	// E.g., {'thumbnail': binary_data }.
	//
	// Unlike attributes, attachments are for binary data and they are not queryable.
	// We limit the maximum size of a single attachment to 4K bytes.
	//
	// The key must be US-ASCII printable characters, excluding the '=' character
	// and should not start with '_' character.
	Attachments Attachments
}

func (Advertisement) __VDLReflect(struct {
	Name string `vdl:"v.io/v23/discovery.Advertisement"`
}) {
}

// An AdId is a globally unique identifier of an advertisement.
type AdId [16]byte

func (AdId) __VDLReflect(struct {
	Name string `vdl:"v.io/v23/discovery.AdId"`
}) {
}

// Attributes represents service attributes as a key/value pair.
type Attributes map[string]string

func (Attributes) __VDLReflect(struct {
	Name string `vdl:"v.io/v23/discovery.Attributes"`
}) {
}

// Attachments represents service attachments as a key/value pair.
type Attachments map[string][]byte

func (Attachments) __VDLReflect(struct {
	Name string `vdl:"v.io/v23/discovery.Attachments"`
}) {
}

func init() {
	vdl.Register((*Advertisement)(nil))
	vdl.Register((*AdId)(nil))
	vdl.Register((*Attributes)(nil))
	vdl.Register((*Attachments)(nil))
}
