discovery

package
v0.0.0-...-7ce9f83 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Overview

Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	// BasePort is the base for the port number that is used by the proxy.
	BasePort = int32(5000)
)

Functions

func Assert

func Assert(event string, f FSMWithBus, done chan struct{}, assert func([]string), topic ...string)

Assert subscribes for a topic in the message bus, waits until the 'event' received, executes the assertions and signals to the done channel once finished. if no assetions are specified, it just verifies that the event was received.

func GenerateEvents

func GenerateEvents(name string, IDs ...string) []*pb.Event

GenerateEvents id is a helper method to generate a list of events produced by discovery clients.

func WaitDoneOrTimeout

func WaitDoneOrTimeout(done chan struct{}, t ...time.Duration)

WaitDoneOrTimeout waits until either something came from the done channel or a timeout occured

Types

type BrokenNetworkChecker

type BrokenNetworkChecker struct {
}

func (*BrokenNetworkChecker) Verify

func (f *BrokenNetworkChecker) Verify(host, port string) error

type BrokenSPDZEngine

type BrokenSPDZEngine struct {
}

func (*BrokenSPDZEngine) Execute

func (b *BrokenSPDZEngine) Execute(*pb.Event) error

type Event

type Event struct {
	Name   string
	GameID string
}

Event is a generic message sent between clients and discovery service.

type FSMWithBus

type FSMWithBus interface {
	History() *fsm.History
	Bus() mb.MessageBus
}

FSMWithBus is a Finate State Machine coupled with message bus.

type FakeBrokenDiscoveryClient

type FakeBrokenDiscoveryClient struct {
	// contains filtered or unexported fields
}

func NewFakeBrokenDiscoveryClient

func NewFakeBrokenDiscoveryClient(bus mb.MessageBus, name string, registered, playersReady bool) *FakeBrokenDiscoveryClient

func (*FakeBrokenDiscoveryClient) GetIn

func (fbdc *FakeBrokenDiscoveryClient) GetIn() chan *pb.Event

GetIn returns In channel of the client.

func (*FakeBrokenDiscoveryClient) GetOut

func (fbdc *FakeBrokenDiscoveryClient) GetOut() chan *pb.Event

GetOut returns Out channel of the client.

func (*FakeBrokenDiscoveryClient) Run

func (fbdc *FakeBrokenDiscoveryClient) Run()

type FakeDClient

type FakeDClient struct {
}

FakeDClient is used in the tests.

func (*FakeDClient) Connect

func (f *FakeDClient) Connect() (*grpc.ClientConn, error)

Connect belongs to a fake, it is used in the tests.

func (*FakeDClient) GetIn

func (f *FakeDClient) GetIn() chan *pb.Event

GetIn returns In channel of the client.

func (*FakeDClient) GetOut

func (f *FakeDClient) GetOut() chan *pb.Event

GetOut returns Out channel of the client.

func (*FakeDClient) Run

func (f *FakeDClient) Run(client pb.DiscoveryClient)

Run belongs to a fake struct, it is not really used.

type FakeDiscoveryClient

type FakeDiscoveryClient struct {
	// contains filtered or unexported fields
}

func NewFakeDiscoveryClient

func NewFakeDiscoveryClient(bus mb.MessageBus, name string) *FakeDiscoveryClient

func (*FakeDiscoveryClient) GetIn

func (fdc *FakeDiscoveryClient) GetIn() chan *pb.Event

GetIn returns In channel of the client.

func (*FakeDiscoveryClient) GetOut

func (fdc *FakeDiscoveryClient) GetOut() chan *pb.Event

GetOut returns Out channel of the client.

func (*FakeDiscoveryClient) Run

func (fdc *FakeDiscoveryClient) Run()

type FakeNetworker

type FakeNetworker struct {
	FreePorts []int32
}

func (*FakeNetworker) CreateNetwork

func (f *FakeNetworker) CreateNetwork(pl *pb.Player) (int32, error)

type FakeTransport

type FakeTransport struct {
}

func (*FakeTransport) Events

func (t *FakeTransport) Events(stream pb.Discovery_EventsServer) error

func (*FakeTransport) GetIn

func (t *FakeTransport) GetIn() chan *pb.Event

func (*FakeTransport) GetOut

func (t *FakeTransport) GetOut() chan *pb.Event

func (*FakeTransport) Run

func (t *FakeTransport) Run(f func()) error

func (*FakeTransport) Stop

func (t *FakeTransport) Stop()

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game is a single execution of MPC.

func NewGame

func NewGame(ctx context.Context, id string, bus mb.MessageBus, stateTimeout time.Duration, computationTimeout time.Duration, logger *zap.SugaredLogger, playerCount int) (*Game, error)

NewGame returns an instance of Game.

func (*Game) Bus

func (g *Game) Bus() mb.MessageBus

Bus returns the bus used by game.

func (*Game) History

func (g *Game) History() *fsm.History

History returns history of Game's FSM

func (*Game) Init

func (g *Game) Init(errCh chan error)

Init starts the fsm of the Game with its initial state.

`errChan` is expected to be a buffered channel with minimum capacity of "1".

type GameCallbacker

type GameCallbacker struct {
	// contains filtered or unexported fields
}

GameCallbacker contains methods to react on game events.

type GamesWithBus

type GamesWithBus struct {
	Games map[string]*Game
	Bus   mb.MessageBus
}

GamesWithBus is tuple of Game and MessageBus

type IstioNetworker

type IstioNetworker struct {
	// contains filtered or unexported fields
}

IstioNetworker is an implementation of Networker interface which creates new networks backed by Istio configuration.

func NewIstioNetworker

func NewIstioNetworker(logger *zap.SugaredLogger, portRange string, delCh chan string) (*IstioNetworker, error)

NewIstioNetworker creates a new IstioNetworker

func (*IstioNetworker) CreateNetwork

func (i *IstioNetworker) CreateNetwork(pl *pb.Player) (int32, error)

CreateNetwork creates a network in the format acceptable by the network controller.

func (*IstioNetworker) Run

func (i *IstioNetworker) Run() error

Run starts the Networker. This method initializes k8s informers and synchorinizes various caches. It also registers a callback which will clean up the resources after pod deletion.

type Networker

type Networker interface {
	CreateNetwork(pl *pb.Player) (int32, error)
}

Networker is an interface that allows to retrieve ports and create network config for MPC apps.

type PlayerID

type PlayerID int32

PlayerID is the id of the MPC player.

type PortsState

type PortsState struct {
	// contains filtered or unexported fields
}

func NewPortsState

func NewPortsState(rng string, used []int32) (*PortsState, error)

func (*PortsState) GetFreePort

func (m *PortsState) GetFreePort() (int32, error)

GetFreePort returns a port that can be assigned or an error if there are no free ports.

func (*PortsState) Sync

func (m *PortsState) Sync(used []int32) error

Sync updates the state based on the currently used ports. It populates the list of released ports and updates the lastUsed pointer. Not thead safe, an external lock must be hold to execute this method.

type Publisher

type Publisher struct {
	Fsm *fsm.FSM
	Bus mb.MessageBus
}

Publisher sends an event to the message bus.

func NewPublisher

func NewPublisher(bus mb.MessageBus) *Publisher

NewPublisher returns a new publisher.

func (*Publisher) Publish

func (p *Publisher) Publish(name, targetTopic string, srcTopics ...string)

Publish sends an FSM event to a given topic of the message bus. Not every call to Publish will have an srcTopic, thus make it of variable size.

func (*Publisher) PublishExternalEvent

func (p *Publisher) PublishExternalEvent(ev *pb.Event, topic string)

PublishExternalEvent publishes an instance of Event as received from the external source.

func (*Publisher) PublishWithBody

func (p *Publisher) PublishWithBody(name, targetTopic string, body *pb.Event, srcTopics ...string)

PublishWithBody wraps a protobuf event into the fsm.Event and publishes it to the message bus.

type ServiceNG

type ServiceNG struct {
	// contains filtered or unexported fields
}

ServiceNG is a new generation of discovery service.

func NewServiceNG

func NewServiceNG(bus mb.MessageBus, pub *Publisher, stateTimeout time.Duration, computationTimeout time.Duration, tr t.Transport, n Networker, frontendAddress string, logger *zap.SugaredLogger, mode string, client DiscoveryClient, playerCount int) *ServiceNG

NewServiceNG returns a new instance of discovery service.

func (*ServiceNG) DeleteCallback

func (s *ServiceNG) DeleteCallback(name string)

DeleteCallback is called when the pod is deleted, so we remove it from our bookkeeping.

func (*ServiceNG) Start

func (s *ServiceNG) Start() error

Start starts listening to incoming messages from clients.

func (*ServiceNG) Stop

func (s *ServiceNG) Stop()

Stop stops the service.

func (*ServiceNG) WaitUntilReady

func (s *ServiceNG) WaitUntilReady(timeout time.Duration) error

WaitUntilReady waits until the service has started until the defined timeout is reached.

type StatesAsserter

type StatesAsserter struct {
	// contains filtered or unexported fields
}

StatesAsserter allows checking for returned states from a Game more easily

func NewStatesAsserter

func NewStatesAsserter(states []string) *StatesAsserter

NewStatesAsserter creates a new StatesAsserter that checks the provided states slice

func (*StatesAsserter) ExpectNext

func (s *StatesAsserter) ExpectNext() Assertion

ExpectNext returns an Assertion over the next element of the internal states slice.

This method does not perform any bounds checking, so calling this one time too many will panic

Directories

Path Synopsis
transport

Jump to

Keyboard shortcuts

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