bad commit ignored cmd

This commit is contained in:
Kyle Isom 2023-06-09 03:39:40 +00:00
parent 9acafceb8f
commit b25a30f355
3 changed files with 96 additions and 2 deletions

4
.gitignore vendored
View File

@ -1,3 +1,3 @@
*.conf
overpush
overpushd
/overpush
/overpushd

53
cmd/overpush/main.go Normal file
View File

@ -0,0 +1,53 @@
package main
import (
"context"
"flag"
"fmt"
"strings"
"time"
"git.wntrmute.dev/kyle/goutils/die"
pb "git.wntrmute.dev/kyle/overpush/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
address := "127.0.0.1:5000"
m := &pb.Message{
Type: pb.MessageType_MessageTypeMessage,
Timestamp: time.Now().Unix(),
Priority: pb.Priority_PriorityNormal,
}
var r string
flag.StringVar(&address, "a", address, "`address` of overpush server")
flag.StringVar(&m.Text, "m", "this is a test message", "`message` text")
flag.StringVar(&m.Title, "t", "test test", "message title")
flag.StringVar(&r, "r", "", "recipients")
flag.Parse()
m.Recipients = strings.Split(r, ",")
if m.Text == "" && m.Title == "" {
die.With("no message or title specified")
}
if m.Title != "" {
m.Type = pb.MessageType_MessageTypeMessageWithTitle
}
var opts = []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
}
conn, err := grpc.Dial(address, opts...)
die.If(err)
defer conn.Close()
client := pb.NewOverpushClient(conn)
resp, err := client.QueueMessage(context.Background(), m)
die.If(err)
fmt.Printf("response status: %d\n", resp.Status)
}

41
cmd/overpushd/main.go Normal file
View File

@ -0,0 +1,41 @@
package main
import (
"flag"
"fmt"
"git.wntrmute.dev/kyle/goutils/config"
"git.wntrmute.dev/kyle/goutils/die"
"git.wntrmute.dev/kyle/goutils/log"
"git.wntrmute.dev/kyle/overpush/server"
)
func main() {
var configFile string
flag.StringVar(&configFile, "f", "", "`path` to config file")
flag.Parse()
if configFile != "" {
err := config.LoadFile(configFile)
die.If(err)
}
logLevel := config.GetDefault("log_level", "WARNING")
opts := log.DefaultOptions("overpush", false)
opts.Level = logLevel
fmt.Println("listing keys:")
for _, k := range config.ListKeys() {
fmt.Printf("\t%s\n", k)
}
err := log.Setup(opts)
die.If(err)
srv, err := server.New()
log.FatalError(err, "failed to set up gRPC server")
go srv.Default.Receive()
log.FatalError(server.Run(srv), "server has died")
}