Documentation ¶
Index ¶
- func NewHandlers(r *Repository)
- func StartPubSubFakeServer(port int) (*grpc.ClientConn, *pstest.Server, error)
- type Message
- type PubSubServer
- type PublisherServiceConfig
- type Repository
- func (repo *Repository) CreateSubscription(ctx context.Context, subID string, topicName string, c *pubsub.Client) (*pubsub.Subscription, error)
- func (repo *Repository) CreateTopic(ctx context.Context, topic string, c *pubsub.Client) error
- func (repo *Repository) GenerateARandomMessage(serviceNames []string) *Message
- func (repo *Repository) GenerateRandomMessages(n uint, serviceNames []string) []Message
- func (repo *Repository) GenerateServicesPool(n uint) []string
- func (repo *Repository) GetPayLoad() string
- func (repo *Repository) GetRandomServiceName(s []string) string
- func (repo *Repository) GetRandomSeverity(min, max int) Severity
- func (repo *Repository) InitPubSubProcess(publishers, serviceNamePoolSize uint, logs chan<- lmslogging.Log, ...)
- func (repo *Repository) NewPubSubClient(ctx context.Context, projectID string) (*pubsub.Client, error)
- func (repo *Repository) PublishBulkMessage(topic string, msg []Message, c *pubsub.Client, ...) error
- func (repo *Repository) SeverityToString(s Severity) string
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartPubSubFakeServer ¶
StartPubSubFakeServer startup a fake server for pub sub
Types ¶
type Message ¶
type Message struct { ServiceName string `json:"service_name"` Payload string `json:"payload"` Severity string `json:"severity"` Timestamp time.Time `json:"timestamp"` }
Message holds the message structure
type PubSubServer ¶
type PubSubServer struct {
Conn *grpc.ClientConn
}
PubSubServer Holds ClientConnection for pstest
type PublisherServiceConfig ¶
PublisherServiceConfig holds the publisher configuration for service workers
type Repository ¶
Repository holds App config
var Repo *Repository
func NewRepo ¶
func NewRepo(a *config.AppConfig) *Repository
NewRepo initialise and return Repository Type Which holds AppConfig
func (*Repository) CreateSubscription ¶
func (repo *Repository) CreateSubscription(ctx context.Context, subID string, topicName string, c *pubsub.Client) (*pubsub.Subscription, error)
CreateSubscription creates a subscription for a given client on a topic
func (*Repository) CreateTopic ¶
CreateTopic receives the message from pub sub
func (*Repository) GenerateARandomMessage ¶
func (repo *Repository) GenerateARandomMessage(serviceNames []string) *Message
GenerateARandomMessage for the pub sub
func (*Repository) GenerateRandomMessages ¶
func (repo *Repository) GenerateRandomMessages(n uint, serviceNames []string) []Message
GenerateRandomMessages for the pub sub it creates multiple messages as slice
func (*Repository) GenerateServicesPool ¶
func (repo *Repository) GenerateServicesPool(n uint) []string
GenerateServicesPool generate some service name for this exercise This function generates "Service-name:1" "Service-name:2"...
func (*Repository) GetPayLoad ¶
func (repo *Repository) GetPayLoad() string
GetPayLoad generates payload as a paragraph. Word count and Sentence count can be adjusted in env Do not set higher values, it will generate very long paragraphs. it can be problematic for SQL inserts and performance
func (*Repository) GetRandomServiceName ¶
func (repo *Repository) GetRandomServiceName(s []string) string
GetRandomServiceName generates random service name for the message this function generates random string only
func (*Repository) GetRandomSeverity ¶
func (repo *Repository) GetRandomSeverity(min, max int) Severity
GetRandomSeverity generates random severity between the range
func (*Repository) InitPubSubProcess ¶
func (repo *Repository) InitPubSubProcess(publishers, serviceNamePoolSize uint, logs chan<- lmslogging.Log, w *sync.WaitGroup, serviceConfig PublisherServiceConfig)
InitPubSubProcess will initialise pub/sub Create a topic from env variable Initialise and run Publishers Fake services concurrently.
func (*Repository) NewPubSubClient ¶
func (repo *Repository) NewPubSubClient(ctx context.Context, projectID string) (*pubsub.Client, error)
NewPubSubClient creates a new client connection for pub/sub
func (*Repository) PublishBulkMessage ¶
func (repo *Repository) PublishBulkMessage(topic string, msg []Message, c *pubsub.Client, msgConfig PublisherServiceConfig) error
PublishBulkMessage publishes a message to given topic
func (*Repository) SeverityToString ¶
func (repo *Repository) SeverityToString(s Severity) string
SeverityToString converts severity to string