mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Write usage information
This commit is contained in:
parent
804d17a427
commit
c9a2c9a8f7
|
|
@ -5,6 +5,7 @@ package main
|
|||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -14,23 +15,45 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const usage = `Usage: %s
|
||||
|
||||
Generate a list of matrix room events for load testing.
|
||||
Writes the events to stdout separated by new lines
|
||||
|
||||
Environment:
|
||||
|
||||
SERVER_NAME The name of the matrix server to generate events for.
|
||||
(default: "localhost")
|
||||
|
||||
KEY_ID The ID of the key used to sign the events.
|
||||
(default: "ed25519:auto")
|
||||
|
||||
PRIVATE_KEY Base64 encoded private key to sign events with
|
||||
(default: <base64 encoded key of 0>)
|
||||
|
||||
ROOM_ID The room ID to generate events in.
|
||||
(default: "!roomid:$SERVER_NAME")
|
||||
|
||||
USER_ID The user ID to use as the event sender.
|
||||
(default: "@userid:$SERVER_NAME")
|
||||
|
||||
MESSAGE_COUNT The number of m.room.messsage events to generate.
|
||||
(default: 10)
|
||||
|
||||
FORMAT The output format to use for the messages.
|
||||
INPUT -> api.InputRoomEvent
|
||||
RAW -> gomatrixserverlib.Event
|
||||
(default: INPUT)
|
||||
`
|
||||
|
||||
var (
|
||||
// The name of the matrix server to generate events for.
|
||||
serverName = defaulting(os.Getenv("SERVER_NAME"), "localhost")
|
||||
// The ID of the key used to sign the events.
|
||||
keyID = defaulting(os.Getenv("KEY_ID"), "ed25519:auto")
|
||||
// Base64 encoded private key to sign the events with.
|
||||
serverName = defaulting(os.Getenv("SERVER_NAME"), "localhost")
|
||||
keyID = defaulting(os.Getenv("KEY_ID"), "ed25519:auto")
|
||||
privateKeyString = defaulting(os.Getenv("PRIVATE_KEY"), defaultKey)
|
||||
// The room ID to generate events in.
|
||||
roomID = defaulting(os.Getenv("ROOM_ID"), "!roomid:"+serverName)
|
||||
// The user ID to use for as the event sender.
|
||||
userID = defaulting(os.Getenv("USER_ID"), "@userid:"+serverName)
|
||||
// The number of m.room.messsage events to generate.
|
||||
messageCount = defaulting(os.Getenv("MESSAGE_COUNT"), "10")
|
||||
// The output format to use for the messages.
|
||||
// INPUT -> api.InputRoomEvent
|
||||
// RAW -> gomatrixserverlib.Event
|
||||
format = defaulting(os.Getenv("FORMAT"), "INPUT")
|
||||
roomID = defaulting(os.Getenv("ROOM_ID"), "!roomid:"+serverName)
|
||||
userID = defaulting(os.Getenv("USER_ID"), "@userid:"+serverName)
|
||||
messageCount = defaulting(os.Getenv("MESSAGE_COUNT"), "10")
|
||||
format = defaulting(os.Getenv("FORMAT"), "INPUT")
|
||||
)
|
||||
|
||||
func defaulting(value, defaultValue string) string {
|
||||
|
|
@ -50,6 +73,10 @@ var b gomatrixserverlib.EventBuilder
|
|||
var eventID int
|
||||
|
||||
func main() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, usage, os.Args[0])
|
||||
}
|
||||
flag.Parse()
|
||||
// Decode the ed25519 private key.
|
||||
privateKeyBytes, err := base64.RawStdEncoding.DecodeString(privateKeyString)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue