Skip to content

Commit

Permalink
Remove unused connect protocol references
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Jan 21, 2024
1 parent d04d8a7 commit a2added
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 641 deletions.
5 changes: 0 additions & 5 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ plugins:
out: internal/gen/proto/go
opt: paths=source_relative

# Remote plugin. You can switch to a local one by using "connect-go".
- plugin: buf.build/bufbuild/connect-go
out: internal/gen/proto/go
opt: paths=source_relative

# Remote plugin. You can switch to a local one by using "timostamm-protobuf-ts".
- plugin: buf.build/community/timostamm-protobuf-ts
out: internal/gen/proto/ts
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/Microsoft/go-winio v0.6.1
github.com/atotto/clipboard v0.1.4
github.com/bufbuild/connect-go v1.10.0
github.com/bufbuild/connect-grpchealth-go v1.1.1
github.com/bufbuild/connect-grpcreflect-go v1.1.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/lipgloss v0.9.1
github.com/cli/cli/v2 v2.42.1
Expand All @@ -25,13 +22,11 @@ require (
github.com/muesli/cancelreader v0.2.2
github.com/oklog/ulid/v2 v2.1.0
github.com/rogpeppe/go-internal v1.12.0
github.com/rs/cors v1.10.1
github.com/rwtodd/Go.Sed v0.0.0-20230610052213-ba3e9c186f0a
github.com/vektah/gqlparser/v2 v2.5.10
github.com/yuin/goldmark v1.6.0
go.uber.org/multierr v1.11.0
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/net v0.20.0
golang.org/x/oauth2 v0.16.0
golang.org/x/sys v0.16.0
golang.org/x/term v0.16.0
Expand All @@ -46,6 +41,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
golang.org/x/net v0.20.0 // indirect
)

require (
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A=
github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE=
github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg=
github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8=
github.com/bufbuild/connect-grpchealth-go v1.1.1 h1:ldceS3m7+Qvl3GI4yzB4oCg3uOdD+Y1bytc/5xuMpqo=
github.com/bufbuild/connect-grpchealth-go v1.1.1/go.mod h1:9KbkogLoUIxOTPKyWDv5evkawr1IYXaHax4XoUHCgoQ=
github.com/bufbuild/connect-grpcreflect-go v1.1.0 h1:T0FKu1y9zZW4cjHuF+Q7jIN6ek8HTpCxOP8ZsORZICg=
github.com/bufbuild/connect-grpcreflect-go v1.1.0/go.mod h1:AxcY2fSAr+oQQuu+K35qy2VDtX+LWr7SrS2SvfjY898=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/charmbracelet/bubbles v0.17.1 h1:0SIyjOnkrsfDo88YvPgAWvZMwXe26TP6drRvmkjyUu4=
github.com/charmbracelet/bubbles v0.17.1/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o=
Expand Down Expand Up @@ -173,8 +167,6 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=
github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/rwtodd/Go.Sed v0.0.0-20230610052213-ba3e9c186f0a h1:URwYffGNuBQkfwkcn+1CZhb8IE/mKSXxPXp/zzQsn80=
github.com/rwtodd/Go.Sed v0.0.0-20230610052213-ba3e9c186f0a/go.mod h1:c6qgHcSUeSISur4+Kcf3WYTvpL07S8eAsoP40hDiQ1I=
Expand Down
99 changes: 4 additions & 95 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,18 @@ package cmd
import (
"crypto/tls"
"net"
"net/http"
"os"
"strings"
"time"

"github.com/bufbuild/connect-go"
grpchealth "github.com/bufbuild/connect-grpchealth-go"
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
"github.com/rs/cors"
"github.com/spf13/cobra"
"github.com/stateful/runme/internal/document/editor/editorservice"
parserv1 "github.com/stateful/runme/internal/gen/proto/go/runme/parser/v1"
projectv1 "github.com/stateful/runme/internal/gen/proto/go/runme/project/v1"
runnerv1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1"
"github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1/runnerv1connect"
"github.com/stateful/runme/internal/project/projectservice"
"github.com/stateful/runme/internal/runner"
runmetls "github.com/stateful/runme/internal/tls"
"go.uber.org/zap"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthgrpc "google.golang.org/grpc/health/grpc_health_v1"
Expand All @@ -36,11 +27,10 @@ func serverCmd() *cobra.Command {
)

var (
addr string
useConnectProtocol bool
devMode bool
enableRunner bool
tlsDir string
addr string
devMode bool
enableRunner bool
tlsDir string
)

cmd := cobra.Command{
Expand Down Expand Up @@ -78,49 +68,6 @@ The kernel is used to run long running processes like shells and interacting wit
}
}

// When web is true, the server command exposes a gRPC-compatible HTTP API.
// Read more on https://connect.build/docs/introduction.
if useConnectProtocol {
mux := http.NewServeMux()
compress1KB := connect.WithCompressMinBytes(1024)
if enableRunner {
runnerService, err := runner.NewRunnerServiceHandler(logger)
if err != nil {
return err
}
mux.Handle(runnerv1connect.NewRunnerServiceHandler(runnerService))
}
mux.Handle(grpchealth.NewHandler(
grpchealth.NewStaticChecker(),
compress1KB,
))
mux.Handle(grpcreflect.NewHandlerV1(
grpcreflect.NewStaticReflector(),
compress1KB,
))
mux.Handle(grpcreflect.NewHandlerV1Alpha(
grpcreflect.NewStaticReflector(),
compress1KB,
))

srv := &http.Server{
Addr: addr,
Handler: h2c.NewHandler(
newCORS().Handler(mux),
&http2.Server{},
),
ReadHeaderTimeout: time.Second,
ReadTimeout: 5 * time.Minute,
WriteTimeout: 5 * time.Minute,
MaxHeaderBytes: 8 * 1024, // 8KiB
TLSConfig: tlsConfig,
}

logger.Info("started listening", zap.String("addr", srv.Addr))

return srv.ListenAndServe()
}

var lis net.Listener
protocol := "tcp"

Expand Down Expand Up @@ -173,7 +120,6 @@ The kernel is used to run long running processes like shells and interacting wit
setDefaultFlags(&cmd)

cmd.Flags().StringVarP(&addr, "address", "a", defaultAddr, "Address to create unix (unix:///path/to/socket) or IP socket (localhost:7890)")
cmd.Flags().BoolVar(&useConnectProtocol, "connect-protocol", false, "Use Connect Protocol (https://connect.build/)")
cmd.Flags().BoolVar(&devMode, "dev", false, "Enable development mode")
cmd.Flags().BoolVar(&enableRunner, "runner", true, "Enable runner service (legacy, defaults to true)")
cmd.Flags().StringVar(&tlsDir, "tls", defaultTLSDir, "Directory in which to generate TLS certificates & use for all incoming and outgoing messages")
Expand All @@ -182,40 +128,3 @@ The kernel is used to run long running processes like shells and interacting wit

return &cmd
}

func newCORS() *cors.Cors {
return cors.New(cors.Options{
AllowedMethods: []string{
http.MethodHead,
http.MethodGet,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
},
AllowOriginFunc: func(origin string) bool {
// Allow all origins, which effectively disables CORS.
return true
},
AllowedHeaders: []string{"*"},
ExposedHeaders: []string{
// Content-Type is in the default safelist.
"Accept",
"Accept-Encoding",
"Accept-Post",
"Connect-Accept-Encoding",
"Connect-Content-Encoding",
"Content-Encoding",
"Grpc-Accept-Encoding",
"Grpc-Encoding",
"Grpc-Message",
"Grpc-Status",
"Grpc-Status-Details-Bin",
},
// Let browsers cache CORS information for longer, which reduces the number
// of preflight requests. Any changes to ExposedHeaders won't take effect
// until the cached data expires. FF caps this value at 24h, and modern
// Chrome caps it at 2h.
MaxAge: int(2 * time.Hour / time.Second),
})
}

This file was deleted.

Loading

0 comments on commit a2added

Please sign in to comment.