code.vegaprotocol.io/vega@v0.79.0/cmd/vegatools/stream.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package tools
    17  
    18  import (
    19  	"code.vegaprotocol.io/vega/core/config"
    20  	"code.vegaprotocol.io/vega/vegatools/stream"
    21  )
    22  
    23  type streamCmd struct {
    24  	config.OutputFlag
    25  	BatchSize uint     `description:"size of the event stream batch of events" long:"batch-size"                                                                               short:"b"`
    26  	Party     string   `description:"name of the party to listen for updates"  long:"party"                                                                                    short:"p"`
    27  	Market    string   `description:"name of the market to listen for updates" long:"market"                                                                                   short:"m"`
    28  	Address   string   `description:"address of the grpc server"               long:"address"                                                                                  required:"true"   short:"a"`
    29  	LogFormat string   `default:"raw"                                          description:"output stream data in specified format. Allowed values: raw (default), text, json" long:"log-format"`
    30  	Reconnect bool     `description:"if connection dies, attempt to reconnect" long:"reconnect"                                                                                short:"r"`
    31  	Type      []string `default:""                                             description:"one or more event types to subscribe to (default=ALL)"                             long:"type"       short:"t"`
    32  }
    33  
    34  func (opts *streamCmd) Execute(_ []string) error {
    35  	return stream.Run(
    36  		opts.BatchSize,
    37  		opts.Party,
    38  		opts.Market,
    39  		opts.Address,
    40  		opts.LogFormat,
    41  		opts.Reconnect,
    42  		opts.Type,
    43  	)
    44  }