subscribe

package
v0.0.0-...-e03dcb5 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = &cobrather.Module{
	Use:   "subscribe",
	Short: "subscribe grpc echo server",
	Flags: []cobrather.Flag{
		flagURL,
		flagMessage,
		flagDuration,
		flagConcurrent,
	},
	RunE: func(ctx context.Context, cmd *cobra.Command, args []string) (err error) {
		logger.DefaultThrottler.SetContext(ctx)
		duration, err := time.ParseDuration(flagDuration.String())
		if err != nil {
			return
		}
		url := flagURL.String()
		message := flagMessage.String()
		concurrent := flagConcurrent.Int64()
		eg, ctx := errgroup.WithContext(ctx)
		for i := int64(0); i < concurrent; i++ {
			eg.Go(func() error {
				changeSubscriberCount(1)
				defer changeSubscriberCount(-1)
				return client.Subscribe(ctx, url, message, duration)
			})
		}
		return eg.Wait()
	},
}

Module info of package

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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