tgsync

package
v0.0.0-...-d99090c Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0, Apache-2.0, MIT Imports: 12 Imported by: 0

README

Testground sync test plan

This test plan utilizes Testground's sync logic to transmit messages from producers to consumers. It does not depend on any additional dependencies, other than the ones already started by Testground.

Getting started

Navigate to the project root directory

# Import the plan
testground plan import --from . --name tg-learning

# Run a test case
testground run single --plan tg-learning --testcase tg-sync-1to1 --builder docker:generic --runner local:docker --instances 4

Documentation

Index

Constants

View Source
const (
	ProducerRole = "producer"
	ConsumerRole = "consumer"
)

Variables

This section is empty.

Functions

func ManyToOne

func ManyToOne(runenv *runtime.RunEnv, initCtx *run.InitContext) error

func OneOnOne

func OneOnOne(runenv *runtime.RunEnv, initCtx *run.InitContext) error

func RunTgSyncTest

func RunTgSyncTest(runenv *runtime.RunEnv, initCtx *run.InitContext, messagesByNode int) error

Types

type TgSyncConsumer

type TgSyncConsumer struct {
	IdGen int32
	// other fields go here as normal
	TotalCount  int
	DoneChannel chan bool
	Client      *sync.DefaultClient
}

func (*TgSyncConsumer) ConsumeMessage

func (cons *TgSyncConsumer) ConsumeMessage(msg *message.DataMessage)

type TgSyncListener

type TgSyncListener struct {
	// The channel to listen at
	ListenChannel <-chan *message.DataMessage
	// The channel to send messages to (basically the consumer)
	NotifyChannel chan<- *message.DataMessage
}

A message listener that uses the Testgorund's sync service channels to receive messages

func (*TgSyncListener) ListenForMessages

func (listener *TgSyncListener) ListenForMessages()

func (*TgSyncListener) SetNotifyChannel

func (listener *TgSyncListener) SetNotifyChannel(channel chan<- *message.DataMessage)

type TgSyncProducer

type TgSyncProducer struct {
	IdGen  int32
	Client *sync.DefaultClient
	Topic  *sync.Topic
}

A message producer that uses Testground's sync channels to produce messages for listeners/consumers

func (*TgSyncProducer) ProduceMessage

func (prod *TgSyncProducer) ProduceMessage(data string)

Jump to

Keyboard shortcuts

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