Skip to content

Commit

Permalink
all: remove office feature
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
changkun committed Jan 6, 2024
1 parent 6448432 commit f623e03
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 779 deletions.
131 changes: 0 additions & 131 deletions api/daemon/office.go

This file was deleted.

10 changes: 1 addition & 9 deletions api/daemon/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"changkun.de/x/midgard/internal/config"
"changkun.de/x/midgard/internal/office"
"changkun.de/x/midgard/internal/types"
"changkun.de/x/midgard/internal/types/proto"
"changkun.de/x/midgard/internal/utils"
Expand All @@ -27,7 +26,6 @@ type Daemon struct {
sync.Mutex

ID string
status office.Status
forceUpdate chan struct{}
s *grpc.Server
ws *websocket.Conn
Expand Down Expand Up @@ -64,7 +62,7 @@ func (m *Daemon) Run(ctx context.Context) (onStart, onStop func() error) {
defer wg.Done()
m.Serve(ctx)
}

onStart = func() error {
wg.Add(1)
go run()
Expand Down Expand Up @@ -104,12 +102,6 @@ func (m *Daemon) Serve(ctx context.Context) {
m.watchLocalClipboard(ctx)
}()
wg.Add(1)
go func() {
defer wg.Done()
defer log.Println("office watcher is terminated.")
m.watchOfficeStatus(ctx)
}()
wg.Add(1)
go func() {
defer wg.Done()
defer log.Println("rpc server is terminated.")
Expand Down
73 changes: 0 additions & 73 deletions api/rest/office.go

This file was deleted.

18 changes: 8 additions & 10 deletions api/rest/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (m *Midgard) routers() (r *gin.Engine) {
mg := r.Group("/midgard")
mg.GET("/ping", m.PingPong)
mg.GET("/code", m.Code)
mg.GET("/office", m.Office)

v1auth := mg.Group("/api/v1", BasicAuthWithAttemptsControl(Credentials{
config.S().Auth.User: config.S().Auth.Pass,
Expand Down Expand Up @@ -75,15 +74,14 @@ func FixPath(p string) string {
//
// Basic Usage:
//
// - use the pprof tool to look at the heap profile:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/heap
// - look at a 30-second CPU profile:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/profile
// - look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/block
// - collect a 5-second execution trace:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/trace?seconds=5
//
// - use the pprof tool to look at the heap profile:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/heap
// - look at a 30-second CPU profile:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/profile
// - look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/block
// - collect a 5-second execution trace:
// go tool pprof localhost:8080/midgard/api/v1/debug/pprof/trace?seconds=5
func profile(r *gin.RouterGroup) {
pprofHandler := func(h http.HandlerFunc) gin.HandlerFunc {
handler := http.HandlerFunc(h)
Expand Down
11 changes: 2 additions & 9 deletions api/rest/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ import (
"time"

"changkun.de/x/midgard/internal/config"
"changkun.de/x/midgard/internal/office"
"changkun.de/x/midgard/internal/utils"
)

// Midgard is the midgard server that serves all API endpoints.
type Midgard struct {
s *http.Server
status *office.Status
s *http.Server

mu sync.Mutex
users *list.List
}

// NewMidgard creates a new midgard server
func NewMidgard() *Midgard {
return &Midgard{status: office.NewStatus(), users: list.New()}
return &Midgard{users: list.New()}
}

// Serve serves Midgard RESTful APIs.
Expand All @@ -61,11 +59,6 @@ func (m *Midgard) Serve() {
}
}()
wg.Add(1)
go func() {
defer wg.Done()
m.refreshStatus(ctx)
}()
wg.Add(1)
go func() {
defer wg.Done()
m.serveHTTP()
Expand Down
6 changes: 0 additions & 6 deletions api/rest/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ func (m *Midgard) Subscribe(c *gin.Context) {
if err != nil {
log.Println("failed to list daemons:", err)
}
case types.ActionUpdateOfficeStatusRequest:
log.Println("update office status request is received.")
err := m.handleOfficeStatusUpdate(conn, u, wsm.Data)
if err != nil {
log.Printf("failed to update office status: %v", err)
}
default:
log.Printf("unsupported message: action(%v), msg(%v)", wsm.Action, utils.BytesToString(msg))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module changkun.de/x/midgard

go 1.20
go 1.21

require (
github.com/gin-gonic/gin v1.9.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
Expand Down Expand Up @@ -80,6 +81,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
Expand Down
24 changes: 0 additions & 24 deletions internal/office/meeting_darwin.go

This file was deleted.

Loading

0 comments on commit f623e03

Please sign in to comment.