model

package
v0.0.0-...-a4bdab3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package model is a generated protocol buffer package.

It is generated from these files:

limits.proto

It has these top-level messages:

IHave
Push
HostTraffic
Traffic
ConnectorHandshake
ResponderHandshake
UseRequest
UseResponse

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLimiter

func NewLimiter(name string, epoch int64) (Limiter, LimiterControl)

func RegisterGossipProtocolServer

func RegisterGossipProtocolServer(s *grpc.Server, srv GossipProtocolServer)

func RegisterLimiterProtocolServer

func RegisterLimiterProtocolServer(s *grpc.Server, srv LimiterProtocolServer)

func Update

func Update(epochData map[Node]*HostTraffic, traffic []*HostTraffic, cb func(kind Facet, used int64))

Run an update. For each node in the incoming traffic report we do not yet know about, update the traffic data for that node. Assemble the combined traffic data updates for each Facet so named, and then call the callback function which knows how to process those.

Types

type ConnectorHandshake

type ConnectorHandshake struct {
	// Types that are valid to be assigned to Hs:
	//	*ConnectorHandshake_IHave
	//	*ConnectorHandshake_Push
	Hs isConnectorHandshake_Hs `protobuf_oneof:"hs"`
}

func (*ConnectorHandshake) Descriptor

func (*ConnectorHandshake) Descriptor() ([]byte, []int)

func (*ConnectorHandshake) GetHs

func (m *ConnectorHandshake) GetHs() isConnectorHandshake_Hs

func (*ConnectorHandshake) GetIHave

func (m *ConnectorHandshake) GetIHave() *IHave

func (*ConnectorHandshake) GetPush

func (m *ConnectorHandshake) GetPush() *Push

func (*ConnectorHandshake) ProtoMessage

func (*ConnectorHandshake) ProtoMessage()

func (*ConnectorHandshake) Reset

func (m *ConnectorHandshake) Reset()

func (*ConnectorHandshake) String

func (m *ConnectorHandshake) String() string

func (*ConnectorHandshake) XXX_OneofFuncs

func (*ConnectorHandshake) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type ConnectorHandshake_IHave

type ConnectorHandshake_IHave struct {
	IHave *IHave `protobuf:"bytes,1,opt,name=iHave,oneof"`
}

type ConnectorHandshake_Push

type ConnectorHandshake_Push struct {
	Push *Push `protobuf:"bytes,2,opt,name=push,oneof"`
}

type Facet

type Facet string

type GossipProtocolClient

type GossipProtocolClient interface {
	Gossip(ctx context.Context, opts ...grpc.CallOption) (GossipProtocol_GossipClient, error)
	Sync(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
}

func NewGossipProtocolClient

func NewGossipProtocolClient(cc *grpc.ClientConn) GossipProtocolClient

type GossipProtocolServer

type GossipProtocolServer interface {
	Gossip(GossipProtocol_GossipServer) error
	Sync(context.Context, *google_protobuf.Empty) (*google_protobuf.Empty, error)
}

type GossipProtocol_GossipClient

type GossipProtocol_GossipClient interface {
	Send(*ConnectorHandshake) error
	Recv() (*ResponderHandshake, error)
	grpc.ClientStream
}

type GossipProtocol_GossipServer

type GossipProtocol_GossipServer interface {
	Send(*ResponderHandshake) error
	Recv() (*ConnectorHandshake, error)
	grpc.ServerStream
}

type HostTraffic

type HostTraffic struct {
	Name    string     `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Traffic []*Traffic `protobuf:"bytes,2,rep,name=traffic" json:"traffic,omitempty"`
}

func Wanted

func Wanted(epochData map[Node]*HostTraffic, wanted []string) []*HostTraffic

func (*HostTraffic) Descriptor

func (*HostTraffic) Descriptor() ([]byte, []int)

func (*HostTraffic) GetName

func (m *HostTraffic) GetName() string

func (*HostTraffic) GetTraffic

func (m *HostTraffic) GetTraffic() []*Traffic

func (*HostTraffic) ProtoMessage

func (*HostTraffic) ProtoMessage()

func (*HostTraffic) Reset

func (m *HostTraffic) Reset()

func (*HostTraffic) String

func (m *HostTraffic) String() string

type IHave

type IHave struct {
	Epoch int64    `protobuf:"varint,1,opt,name=epoch" json:"epoch,omitempty"`
	Hosts []string `protobuf:"bytes,2,rep,name=hosts" json:"hosts,omitempty"`
}

func (*IHave) Descriptor

func (*IHave) Descriptor() ([]byte, []int)

func (*IHave) GetEpoch

func (m *IHave) GetEpoch() int64

func (*IHave) GetHosts

func (m *IHave) GetHosts() []string

func (*IHave) ProtoMessage

func (*IHave) ProtoMessage()

func (*IHave) Reset

func (m *IHave) Reset()

func (*IHave) String

func (m *IHave) String() string

type Limiter

type Limiter interface {
	// We want a particular amount of a limit. Tell us how much we can have.
	Ask(limit string, want int64) int64

	// Get the current level
	Level(limit string) int64
}

User-facing interface

type LimiterControl

type LimiterControl interface {
	AddLimit(limit string, upper int64, additional int64, every int64)
}

Interface for managing new limits

type LimiterProtocolClient

type LimiterProtocolClient interface {
	Use(ctx context.Context, in *UseRequest, opts ...grpc.CallOption) (*UseResponse, error)
}

func NewLimiterProtocolClient

func NewLimiterProtocolClient(cc *grpc.ClientConn) LimiterProtocolClient

type LimiterProtocolServer

type LimiterProtocolServer interface {
	Use(context.Context, *UseRequest) (*UseResponse, error)
}

type LimiterSPI

type LimiterSPI interface {
	// Report the current epoch
	Epoch() int64

	Tick(newEpoch int64)

	// Prepare to gossip with a node
	GossipOut() *IHave

	// Respond to initial gossip request from a peer
	GossipIn(ih *IHave) *ResponderHandshake

	// Respond to a push update, either side
	ReceivePush(epoch int64, traffic []*HostTraffic)

	// Send a requested set of host details
	OriginatePush(epoch int64, wanted []string) []*HostTraffic
}

Service-facing interface

type Node

type Node string

type Push

type Push struct {
	Traffic []*HostTraffic `protobuf:"bytes,1,rep,name=traffic" json:"traffic,omitempty"`
}

func Respond

func Respond(table map[Node]*HostTraffic, theyHave []string) ([]string, *Push)

func (*Push) Descriptor

func (*Push) Descriptor() ([]byte, []int)

func (*Push) GetTraffic

func (m *Push) GetTraffic() []*HostTraffic

func (*Push) ProtoMessage

func (*Push) ProtoMessage()

func (*Push) Reset

func (m *Push) Reset()

func (*Push) String

func (m *Push) String() string

type ResponderHandshake

type ResponderHandshake struct {
	IWant []string `protobuf:"bytes,1,rep,name=iWant" json:"iWant,omitempty"`
	Push  *Push    `protobuf:"bytes,2,opt,name=push" json:"push,omitempty"`
}

func (*ResponderHandshake) Descriptor

func (*ResponderHandshake) Descriptor() ([]byte, []int)

func (*ResponderHandshake) GetIWant

func (m *ResponderHandshake) GetIWant() []string

func (*ResponderHandshake) GetPush

func (m *ResponderHandshake) GetPush() *Push

func (*ResponderHandshake) ProtoMessage

func (*ResponderHandshake) ProtoMessage()

func (*ResponderHandshake) Reset

func (m *ResponderHandshake) Reset()

func (*ResponderHandshake) String

func (m *ResponderHandshake) String() string

type Traffic

type Traffic struct {
	Facet string `protobuf:"bytes,1,opt,name=facet" json:"facet,omitempty"`
	Usage int64  `protobuf:"varint,2,opt,name=usage" json:"usage,omitempty"`
}

func (*Traffic) Descriptor

func (*Traffic) Descriptor() ([]byte, []int)

func (*Traffic) GetFacet

func (m *Traffic) GetFacet() string

func (*Traffic) GetUsage

func (m *Traffic) GetUsage() int64

func (*Traffic) ProtoMessage

func (*Traffic) ProtoMessage()

func (*Traffic) Reset

func (m *Traffic) Reset()

func (*Traffic) String

func (m *Traffic) String() string

type UseRequest

type UseRequest struct {
	Facet    string `protobuf:"bytes,1,opt,name=facet" json:"facet,omitempty"`
	Quantity int64  `protobuf:"varint,2,opt,name=quantity" json:"quantity,omitempty"`
}

func (*UseRequest) Descriptor

func (*UseRequest) Descriptor() ([]byte, []int)

func (*UseRequest) GetFacet

func (m *UseRequest) GetFacet() string

func (*UseRequest) GetQuantity

func (m *UseRequest) GetQuantity() int64

func (*UseRequest) ProtoMessage

func (*UseRequest) ProtoMessage()

func (*UseRequest) Reset

func (m *UseRequest) Reset()

func (*UseRequest) String

func (m *UseRequest) String() string

type UseResponse

type UseResponse struct {
	Facet     string `protobuf:"bytes,1,opt,name=facet" json:"facet,omitempty"`
	Quantity  int64  `protobuf:"varint,2,opt,name=quantity" json:"quantity,omitempty"`
	Remaining int64  `protobuf:"varint,3,opt,name=remaining" json:"remaining,omitempty"`
}

func (*UseResponse) Descriptor

func (*UseResponse) Descriptor() ([]byte, []int)

func (*UseResponse) GetFacet

func (m *UseResponse) GetFacet() string

func (*UseResponse) GetQuantity

func (m *UseResponse) GetQuantity() int64

func (*UseResponse) GetRemaining

func (m *UseResponse) GetRemaining() int64

func (*UseResponse) ProtoMessage

func (*UseResponse) ProtoMessage()

func (*UseResponse) Reset

func (m *UseResponse) Reset()

func (*UseResponse) String

func (m *UseResponse) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL