Skip to content

Commit

Permalink
Rename http-server -> http, grpc-server -> grpc
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Doherty <[email protected]>
  • Loading branch information
chrisdoherty4 committed May 2, 2022
1 parent 25db0b5 commit 8902d05
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions cmd/hegel/root_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/tinkerbell/hegel/datamodel"
grpcserver "github.com/tinkerbell/hegel/grpc-server"
"github.com/tinkerbell/hegel/grpc"
"github.com/tinkerbell/hegel/hardware"
httpserver "github.com/tinkerbell/hegel/http-server"
"github.com/tinkerbell/hegel/http"
"github.com/tinkerbell/hegel/metrics"
)

Expand Down Expand Up @@ -149,14 +149,14 @@ func (c *RootCommand) Run(cmd *cobra.Command, _ []string) error {
return errors.Errorf("create client: %v", err)
}

grpcServer := grpcserver.NewServer(logger, hardwareClient)
grpcServer := grpc.NewServer(logger, hardwareClient)

ctx, cancel := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
var routines run.Group

routines.Add(
func() error {
return httpserver.Serve(
return http.Serve(
ctx,
logger,
hardwareClient,
Expand All @@ -173,7 +173,7 @@ func (c *RootCommand) Run(cmd *cobra.Command, _ []string) error {

routines.Add(
func() error {
return grpcserver.Serve(
return grpc.Serve(
ctx,
logger,
grpcServer,
Expand Down
2 changes: 1 addition & 1 deletion grpc-server/grpc_helpers_test.go → grpc/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package grpcserver
package grpc

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion grpc-server/grpc_server.go → grpc/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package grpcserver
package grpc

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion grpc-server/grpc_server_test.go → grpc/server_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package grpcserver
package grpc

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package grpcserver
package grpc

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions http-server/http_handlers.go → http/handlers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package httpserver
package http

import (
"bytes"
Expand All @@ -15,7 +15,7 @@ import (
"github.com/pkg/errors"
"github.com/tinkerbell/hegel/build"
"github.com/tinkerbell/hegel/datamodel"
grpcserver "github.com/tinkerbell/hegel/grpc-server"
"github.com/tinkerbell/hegel/grpc"
"github.com/tinkerbell/hegel/hardware"
"github.com/tinkerbell/hegel/metrics"
)
Expand Down Expand Up @@ -311,7 +311,7 @@ func jsonError(logger log.Logger, w http.ResponseWriter, status int, err error,
// todo(chrisdoherty4) Re-write this. It violates several laws and is dangerously fragile.
// Also, does this work for `/subscriptions`? The writeJSON call injects a function that isn't
// handled properly by writeJSON.
func SubscriptionsHandler(server *grpcserver.Server, logger log.Logger) http.Handler {
func SubscriptionsHandler(server *grpc.Server, logger log.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
getid := strings.TrimPrefix(r.URL.Path, "/subscriptions/")
server.SubLock().RLock()
Expand Down
6 changes: 3 additions & 3 deletions http-server/http_server.go → http/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package httpserver
package http

import (
"context"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/tinkerbell/hegel/datamodel"
grpcserver "github.com/tinkerbell/hegel/grpc-server"
"github.com/tinkerbell/hegel/grpc"
"github.com/tinkerbell/hegel/hardware"
"github.com/tinkerbell/hegel/xff"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
Expand All @@ -21,7 +21,7 @@ func Serve(
ctx context.Context,
logger log.Logger,
client hardware.Client,
grpcsrv *grpcserver.Server,
grpcsrv *grpc.Server,
port int,
start time.Time,
model datamodel.DataModel,
Expand Down
6 changes: 3 additions & 3 deletions http-server/http_server_test.go → http/server_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package httpserver
package http

import (
"context"
Expand All @@ -16,7 +16,7 @@ import (
"github.com/packethost/pkg/log"
"github.com/stretchr/testify/require"
"github.com/tinkerbell/hegel/datamodel"
grpcserver "github.com/tinkerbell/hegel/grpc-server"
"github.com/tinkerbell/hegel/grpc"
"github.com/tinkerbell/hegel/hardware"
"github.com/tinkerbell/hegel/hardware/mock"
_ "github.com/tinkerbell/hegel/metrics" // Initialize metrics.
Expand Down Expand Up @@ -892,7 +892,7 @@ func TestServe(t *testing.T) {
customEndpoints := `{"/metadata":".metadata.instance"}`

go func() {
if err := Serve(context.Background(), logger, mock.HardwareClient{}, &grpcserver.Server{}, mport, time.Now(), "", customEndpoints, ""); err != nil {
if err := Serve(context.Background(), logger, mock.HardwareClient{}, &grpc.Server{}, mport, time.Now(), "", customEndpoints, ""); err != nil {
t.Errorf("Serve() error = %v", err)
}
}()
Expand Down

0 comments on commit 8902d05

Please sign in to comment.