github.com/anycable/anycable-go@v1.5.1/cmd/gobench-cable/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"log/slog"
     7  	"os"
     8  
     9  	"github.com/anycable/anycable-go/cli"
    10  	"github.com/anycable/anycable-go/config"
    11  	_ "github.com/anycable/anycable-go/diagnostics"
    12  	"github.com/anycable/anycable-go/gobench"
    13  	"github.com/anycable/anycable-go/metrics"
    14  	"github.com/anycable/anycable-go/node"
    15  )
    16  
    17  func main() {
    18  	c, err, ok := cli.NewConfigFromCLI(os.Args)
    19  	if err != nil {
    20  		log.Fatalf("%v", err)
    21  	}
    22  	if ok {
    23  		os.Exit(0)
    24  	}
    25  
    26  	opts := []cli.Option{
    27  		cli.WithName("GoBenchCable"),
    28  		cli.WithController(func(m *metrics.Metrics, c *config.Config, l *slog.Logger) (node.Controller, error) {
    29  			return gobench.NewController(m, l), nil
    30  		}),
    31  		cli.WithDefaultBroker(),
    32  		cli.WithDefaultSubscriber(),
    33  		cli.WithDefaultBroadcaster(),
    34  	}
    35  
    36  	runner, err := cli.NewRunner(c, opts)
    37  
    38  	if err != nil {
    39  		fmt.Printf("%+v\n", err)
    40  		os.Exit(1)
    41  	}
    42  
    43  	err = runner.Run()
    44  
    45  	if err != nil {
    46  		fmt.Printf("%+v\n", err)
    47  		os.Exit(1)
    48  	}
    49  }