Skip to content

Commit

Permalink
refactor: Use new Hydrapp UI package interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Felicitas Pojtinger <[email protected]>
  • Loading branch information
pojntfx committed Jul 15, 2024
1 parent a023356 commit 487eb23
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/loopholelabs/latensee
go 1.21.1

require (
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240628064146-489ed4bcd969
github.com/pojntfx/panrpc/go v0.0.0-20240530214555-23871be1d846
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240715213343-ceb622bc2ff4
github.com/pojntfx/panrpc/go v0.0.0-20240702184342-b89dd0c1dde5
github.com/redis/go-redis/v9 v9.5.3
nhooyr.io/websocket v1.8.11
)
Expand All @@ -23,12 +23,12 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
github.com/ncruces/zenity v0.10.12 // indirect
github.com/ncruces/zenity v0.10.13 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
yrh.dev/icns v0.0.0-20210608051050-de3ea6a57b33 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8=
github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
github.com/ncruces/zenity v0.10.12 h1:o4SErDa0kQijlqG6W4OYYzO6kA0fGu34uegvJGcMLBI=
github.com/ncruces/zenity v0.10.12/go.mod h1:5OZIERViRR2fN0FcJCcisqxI+lYMDGzEDCEwB/+8iao=
github.com/ncruces/zenity v0.10.13 h1:0Gd/EdjjEQIhrFaJ05Q5ZvyjlcjnorlZpdzgUzqQIH0=
github.com/ncruces/zenity v0.10.13/go.mod h1:UyAUPSjHm1hOdeZa3Lrh/zmItyGq+iH5AP6xSCx8CFM=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240628064146-489ed4bcd969 h1:Zh6Ny582ycerRjzFpFtGt0j8BLvUMX6mFZiwADB12jY=
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240628064146-489ed4bcd969/go.mod h1:STH543zGexAUq9X/P0reiLTBak/A1cI23Ru+nHhYQDs=
github.com/pojntfx/panrpc/go v0.0.0-20240530214555-23871be1d846 h1:Unf/mgvAgw4Ywc0re5OueAAao0Dumg/FoT0pjsa+3OA=
github.com/pojntfx/panrpc/go v0.0.0-20240530214555-23871be1d846/go.mod h1:qHyKsrQMPKgkOhvGk6xNo9dpS++GIlsh9svE/26lnnM=
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240715213343-ceb622bc2ff4 h1:9umY+sKfhPVfHQhrau2Qjd2zWv4+ZgFWWCKEV8gJ+6o=
github.com/pojntfx/hydrapp/hydrapp v0.0.0-20240715213343-ceb622bc2ff4/go.mod h1:STH543zGexAUq9X/P0reiLTBak/A1cI23Ru+nHhYQDs=
github.com/pojntfx/panrpc/go v0.0.0-20240702184342-b89dd0c1dde5 h1:tqqAYRpCs0iLycOX4Pus6rndb8RqNGJvR5TPxxvzFUY=
github.com/pojntfx/panrpc/go v0.0.0-20240702184342-b89dd0c1dde5/go.mod h1:qHyKsrQMPKgkOhvGk6xNo9dpS++GIlsh9svE/26lnnM=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 h1:GranzK4hv1/pqTIhMTXt2X8MmMOuH3hMeUR0o9SP5yc=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844/go.mod h1:T1TLSfyWVBRXVGzWd0o9BI4kfoO9InEgfQe4NV3mLz8=
github.com/redis/go-redis/v9 v9.5.3 h1:fOAp1/uJG+ZtcITgZOfYFmTKPE7n4Vclj1wZFgRciUU=
Expand All @@ -62,8 +62,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand All @@ -86,8 +86,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
Expand Down
38 changes: 24 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"log"
"os"
"time"
Expand All @@ -27,25 +29,28 @@ func main() {

cfg, err := config.Parse(bytes.NewBuffer(configFile))
if err != nil {
ui.HandlePanic("App", "could not parse config file", err)
ui.HandleFatalPanic("App", errors.Join(fmt.Errorf("could not parse config file"), err))

return
}

// Apply the self-update
browserState := &ui.BrowserState{}
go ui.SelfUpdate(
ctx,
go func() {
if err := ui.SelfUpdate(
ctx,

cfg,
browserState,
ui.HandlePanic,
)
cfg,
browserState,
); err != nil {
ui.HandleFatalPanic(cfg.App.Name, err)
}
}()

// Start the backend
backendURL, stopBackend, err := backend.StartServer(ctx, os.Getenv(ui.EnvBackendLaddr), time.Second*10, true)
if err != nil {
ui.HandlePanic(cfg.App.Name, "could not start backend", err)
ui.HandleFatalPanic(cfg.App.Name, errors.Join(fmt.Errorf("could not start backend"), err))
}
defer stopBackend()

Expand All @@ -54,14 +59,16 @@ func main() {
// Start the frontend
frontendURL, stopFrontend, err := frontend.StartServer(ctx, os.Getenv(ui.EnvFrontendLaddr), backendURL, true)
if err != nil {
ui.HandlePanic(cfg.App.Name, "could not start frontend", err)
ui.HandleFatalPanic(cfg.App.Name, errors.Join(fmt.Errorf("could not start frontend"), err))
}
defer stopFrontend()

log.Println("Frontend URL:", frontendURL)

for {
if !ui.LaunchBrowser(
retry, err := ui.LaunchBrowser(
ctx,

frontendURL,
cfg.App.Name,
cfg.App.ID,
Expand All @@ -75,11 +82,14 @@ func main() {
ui.LynxLikeBrowsers,

browserState,
func(msg string, err error) {
ui.HandlePanic(cfg.App.Name, msg, err)
},
ui.ConfigureBrowser,
) {
)

if err != nil {
ui.HandleFatalPanic(cfg.App.Name, err)
}

if !retry {
return
}
}
Expand Down

0 comments on commit 487eb23

Please sign in to comment.