fixup! wip: refactor: API
This commit is contained in:
parent
c5724dfe59
commit
5aa1be2066
@ -13,9 +13,9 @@ import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"git.netflux.io/rob/octoplex/internal/app"
|
||||
"git.netflux.io/rob/octoplex/internal/config"
|
||||
"git.netflux.io/rob/octoplex/internal/domain"
|
||||
"git.netflux.io/rob/octoplex/internal/server"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
@ -106,7 +106,7 @@ func run() error {
|
||||
return fmt.Errorf("new docker client: %w", err)
|
||||
}
|
||||
|
||||
app := app.New(app.Params{
|
||||
app := server.New(server.Params{
|
||||
ConfigService: configService,
|
||||
DockerClient: dockerClient,
|
||||
ConfigFilePath: configService.Path(),
|
||||
|
2
go.mod
2
go.mod
@ -12,6 +12,7 @@ require (
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/testcontainers/testcontainers-go v0.35.0
|
||||
golang.design/x/clipboard v0.7.0
|
||||
golang.org/x/sync v0.13.0
|
||||
google.golang.org/grpc v1.69.4
|
||||
google.golang.org/protobuf v1.36.3
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
@ -98,7 +99,6 @@ require (
|
||||
golang.org/x/mobile v0.0.0-20250408133729-978277e7eaf7 // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/net v0.39.0 // indirect
|
||||
golang.org/x/sync v0.13.0 // indirect
|
||||
golang.org/x/sys v0.32.0 // indirect
|
||||
golang.org/x/term v0.31.0 // indirect
|
||||
golang.org/x/text v0.24.0 // indirect
|
||||
|
@ -3,13 +3,13 @@ package client
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"git.netflux.io/rob/octoplex/internal/domain"
|
||||
"git.netflux.io/rob/octoplex/internal/event"
|
||||
pb "git.netflux.io/rob/octoplex/internal/generated/grpc"
|
||||
"git.netflux.io/rob/octoplex/internal/protocol"
|
||||
"git.netflux.io/rob/octoplex/internal/terminal"
|
||||
"github.com/sagikazarmark/slog-shim"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
@ -1,6 +1,6 @@
|
||||
//go:build integration
|
||||
|
||||
package app_test
|
||||
package client_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -15,11 +15,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.netflux.io/rob/octoplex/internal/app"
|
||||
"git.netflux.io/rob/octoplex/internal/client"
|
||||
"git.netflux.io/rob/octoplex/internal/config"
|
||||
"git.netflux.io/rob/octoplex/internal/container"
|
||||
"git.netflux.io/rob/octoplex/internal/domain"
|
||||
"git.netflux.io/rob/octoplex/internal/server"
|
||||
"git.netflux.io/rob/octoplex/internal/terminal"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -32,7 +32,7 @@ func buildClientServer(
|
||||
screen tcell.SimulationScreen,
|
||||
screenCaptureC chan<- terminal.ScreenCapture,
|
||||
logger *slog.Logger,
|
||||
) (*client.App, *app.App) {
|
||||
) (*client.App, *server.App) {
|
||||
client := client.New(client.NewParams{
|
||||
BuildInfo: domain.BuildInfo{Version: "0.0.1", GoVersion: "go1.16.3"},
|
||||
Screen: &terminal.Screen{
|
||||
@ -44,7 +44,7 @@ func buildClientServer(
|
||||
Logger: logger,
|
||||
})
|
||||
|
||||
server := app.New(app.Params{
|
||||
server := server.New(server.Params{
|
||||
ConfigService: configService,
|
||||
DockerClient: dockerClient,
|
||||
Logger: logger,
|
||||
@ -62,7 +62,7 @@ func runClientServer(
|
||||
ctx context.Context,
|
||||
_ *testing.T,
|
||||
clientApp *client.App,
|
||||
serverApp *app.App,
|
||||
serverApp *server.App,
|
||||
) <-chan clientServerResult {
|
||||
ch := make(chan clientServerResult, 1)
|
||||
|
@ -1,6 +1,6 @@
|
||||
//go:build integration
|
||||
|
||||
package app_test
|
||||
package client_test
|
||||
|
||||
import (
|
||||
"cmp"
|
@ -5,14 +5,16 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
|
||||
"git.netflux.io/rob/octoplex/internal/event"
|
||||
pb "git.netflux.io/rob/octoplex/internal/generated/grpc"
|
||||
"git.netflux.io/rob/octoplex/internal/protocol"
|
||||
"github.com/sagikazarmark/slog-shim"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Server is the gRPC server that handles incoming commands and outgoing
|
||||
// events.
|
||||
type Server struct {
|
||||
pb.UnimplementedInternalAPIServer
|
||||
|
||||
@ -21,7 +23,8 @@ type Server struct {
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func New(
|
||||
// newServer creates a new gRPC server.
|
||||
func newServer(
|
||||
dispatcher func(event.Command),
|
||||
bus *event.Bus,
|
||||
logger *slog.Logger,
|
@ -1,4 +1,4 @@
|
||||
package app
|
||||
package server
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
@ -18,7 +18,6 @@ import (
|
||||
pb "git.netflux.io/rob/octoplex/internal/generated/grpc"
|
||||
"git.netflux.io/rob/octoplex/internal/mediaserver"
|
||||
"git.netflux.io/rob/octoplex/internal/replicator"
|
||||
"git.netflux.io/rob/octoplex/internal/server"
|
||||
"github.com/docker/docker/client"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@ -83,7 +82,7 @@ func (a *App) Run(ctx context.Context) error {
|
||||
grpcServer := grpc.NewServer()
|
||||
grpcDone := make(chan error, 1)
|
||||
|
||||
pb.RegisterInternalAPIServer(grpcServer, server.New(a.DispatchAsync, a.eventBus, a.logger))
|
||||
pb.RegisterInternalAPIServer(grpcServer, newServer(a.DispatchAsync, a.eventBus, a.logger))
|
||||
go func() {
|
||||
a.logger.Info("gRPC server started", "addr", grpcAddr)
|
||||
grpcDone <- grpcServer.Serve(lis)
|
@ -1,4 +1,4 @@
|
||||
package app
|
||||
package server
|
||||
|
||||
import (
|
||||
"testing"
|
Loading…
x
Reference in New Issue
Block a user