Moved endpoint handlers in tree

This commit is contained in:
Peter 2021-01-13 18:07:04 +01:00
parent bb9f45ce91
commit dc4a9b18a3
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
33 changed files with 55 additions and 55 deletions

View file

@ -2,11 +2,11 @@ package main
import (
"gitlab.com/inetmock/inetmock/internal/cmd"
_ "gitlab.com/inetmock/inetmock/plugins/dns_mock"
_ "gitlab.com/inetmock/inetmock/plugins/http_mock"
_ "gitlab.com/inetmock/inetmock/plugins/http_proxy"
_ "gitlab.com/inetmock/inetmock/plugins/metrics_exporter"
_ "gitlab.com/inetmock/inetmock/plugins/tls_interceptor"
_ "gitlab.com/inetmock/inetmock/internal/endpoint/handler/dns/mock"
_ "gitlab.com/inetmock/inetmock/internal/endpoint/handler/http/mock"
_ "gitlab.com/inetmock/inetmock/internal/endpoint/handler/http/proxy"
_ "gitlab.com/inetmock/inetmock/internal/endpoint/handler/metrics"
_ "gitlab.com/inetmock/inetmock/internal/endpoint/handler/tls/interceptor"
)
func main() {

View file

@ -9,7 +9,7 @@ import (
"syscall"
"github.com/spf13/cobra"
"gitlab.com/inetmock/inetmock/internal/endpoints"
"gitlab.com/inetmock/inetmock/internal/endpoint"
"gitlab.com/inetmock/inetmock/pkg/api"
"gitlab.com/inetmock/inetmock/pkg/audit"
"gitlab.com/inetmock/inetmock/pkg/audit/sink"
@ -31,7 +31,7 @@ type App interface {
api.PluginContext
Config() config.Config
Checker() health.Checker
EndpointManager() endpoints.EndpointManager
EndpointManager() endpoint.EndpointManager
HandlerRegistry() api.HandlerRegistry
Context() context.Context
MustRun()
@ -45,7 +45,7 @@ type app struct {
rootLogger logging.Logger
certStore cert.Store
checker health.Checker
endpointManager endpoints.EndpointManager
endpointManager endpoint.EndpointManager
registry api.HandlerRegistry
ctx context.Context
cancel context.CancelFunc
@ -81,7 +81,7 @@ func (a app) Checker() health.Checker {
return a.checker
}
func (a app) EndpointManager() endpoints.EndpointManager {
func (a app) EndpointManager() endpoint.EndpointManager {
return a.endpointManager
}
@ -144,7 +144,7 @@ func NewApp(registrations ...api.Registration) (inetmockApp App, err error) {
return
}
a.endpointManager = endpoints.NewEndpointManager(
a.endpointManager = endpoint.NewEndpointManager(
a.registry,
a.Logger().Named("EndpointManager"),
a.checker,

View file

@ -5,11 +5,11 @@ import (
"os"
"gitlab.com/inetmock/inetmock/internal/app"
"gitlab.com/inetmock/inetmock/plugins/dns_mock"
"gitlab.com/inetmock/inetmock/plugins/http_mock"
"gitlab.com/inetmock/inetmock/plugins/http_proxy"
"gitlab.com/inetmock/inetmock/plugins/metrics_exporter"
"gitlab.com/inetmock/inetmock/plugins/tls_interceptor"
"gitlab.com/inetmock/inetmock/internal/endpoint/handler/dns/mock"
mock2 "gitlab.com/inetmock/inetmock/internal/endpoint/handler/http/mock"
"gitlab.com/inetmock/inetmock/internal/endpoint/handler/http/proxy"
"gitlab.com/inetmock/inetmock/internal/endpoint/handler/metrics"
"gitlab.com/inetmock/inetmock/internal/endpoint/handler/tls/interceptor"
)
var (
@ -19,11 +19,11 @@ var (
func ExecuteServerCommand() {
var err error
if server, err = app.NewApp(
http_mock.AddHTTPMock,
dns_mock.AddDNSMock,
tls_interceptor.AddTLSInterceptor,
http_proxy.AddHTTPProxy,
metrics_exporter.AddMetricsExporter,
mock2.AddHTTPMock,
mock.AddDNSMock,
interceptor.AddTLSInterceptor,
proxy.AddHTTPProxy,
metrics.AddMetricsExporter,
); err != nil {
fmt.Println(err.Error())
os.Exit(1)

View file

@ -1,4 +1,4 @@
package endpoints
package endpoint
import "time"

View file

@ -1,5 +1,5 @@
//go:generate mockgen -source=$GOFILE -destination=./../../internal/mock/endpoints/endpoint.mock.go -package=endpoints_mock
package endpoints
package endpoint
import (
"context"

View file

@ -1,4 +1,4 @@
package endpoints
package endpoint
import (
"context"

View file

@ -1,4 +1,4 @@
package endpoints
package endpoint
import (
"reflect"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"encoding/binary"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"net"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"context"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"net"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"net"

View file

@ -1,4 +1,4 @@
package dns_mock
package mock
import (
"github.com/prometheus/client_golang/prometheus"

View file

@ -1,4 +1,4 @@
package http_mock
package mock
import (
"context"

View file

@ -1,4 +1,4 @@
package http_mock
package mock
import (
"context"

View file

@ -1,4 +1,4 @@
package http_mock_test
package mock_test
import (
"context"
@ -13,12 +13,12 @@ import (
"github.com/golang/mock/gomock"
"github.com/spf13/viper"
"gitlab.com/inetmock/inetmock/internal/endpoint/handler/http/mock"
api_mock "gitlab.com/inetmock/inetmock/internal/mock/api"
audit_mock "gitlab.com/inetmock/inetmock/internal/mock/audit"
"gitlab.com/inetmock/inetmock/pkg/api"
"gitlab.com/inetmock/inetmock/pkg/config"
"gitlab.com/inetmock/inetmock/pkg/logging"
"gitlab.com/inetmock/inetmock/plugins/http_mock"
"go.uber.org/zap"
)
@ -65,7 +65,7 @@ func setupHandler(b *testing.B, ctrl *gomock.Controller, listenPort uint16) (api
b.Helper()
registry := api.NewHandlerRegistry()
if err := http_mock.AddHTTPMock(registry); err != nil {
if err := mock.AddHTTPMock(registry); err != nil {
b.Errorf("AddHTTPMock() error = %v", err)
}
handler, ok := registry.HandlerForName("http_mock")

View file

@ -1,5 +1,5 @@
//go:generate go-enum -f $GOFILE --lower --marshal --names
package http_mock
package mock
import (
"net/http"

View file

@ -1,4 +1,4 @@
package http_mock
package mock
import (
"path/filepath"

View file

@ -1,4 +1,4 @@
package http_mock
package mock
import (
"net/http"

View file

@ -1,4 +1,4 @@
package http_mock
package mock
import (
"github.com/prometheus/client_golang/prometheus"

View file

@ -1,4 +1,4 @@
package http_proxy
package proxy
import (
"context"

View file

@ -1,4 +1,4 @@
package http_proxy
package proxy
import (
"fmt"

View file

@ -1,4 +1,4 @@
package http_proxy
package proxy
import (
"context"

View file

@ -1,4 +1,4 @@
package http_proxy
package proxy
import (
"github.com/prometheus/client_golang/prometheus"

View file

@ -1,4 +1,4 @@
package metrics_exporter
package metrics
import (
"context"

View file

@ -1,4 +1,4 @@
package metrics_exporter
package metrics
type metricsExporterOptions struct {
Route string

View file

@ -1,4 +1,4 @@
package metrics_exporter
package metrics
import (
"gitlab.com/inetmock/inetmock/pkg/api"

View file

@ -1,4 +1,4 @@
package tls_interceptor
package interceptor
import (
"context"

View file

@ -1,4 +1,4 @@
package tls_interceptor
package interceptor
import (
"fmt"

View file

@ -1,4 +1,4 @@
package tls_interceptor
package interceptor
import (
"net"

View file

@ -1,4 +1,4 @@
package tls_interceptor
package interceptor
import (
"fmt"

View file

@ -1,4 +1,4 @@
package tls_interceptor
package interceptor
import (
"sync"

View file

@ -3,12 +3,12 @@ package rpc
import (
"context"
"gitlab.com/inetmock/inetmock/internal/endpoints"
"gitlab.com/inetmock/inetmock/internal/endpoint"
)
type endpointsServer struct {
UnimplementedEndpointsServer
endpointsManager endpoints.EndpointManager
endpointsManager endpoint.EndpointManager
}
func (e endpointsServer) GetEndpoints(_ context.Context, _ *GetEndpointsRequest) (*GetEndpointsResponse, error) {
@ -18,7 +18,7 @@ func (e endpointsServer) GetEndpoints(_ context.Context, _ *GetEndpointsRequest)
}, nil
}
func rpcEndpointsFromEndpoints(eps []endpoints.Endpoint) *[]*Endpoint {
func rpcEndpointsFromEndpoints(eps []endpoint.Endpoint) *[]*Endpoint {
out := make([]*Endpoint, 0)
for _, ep := range eps {
out = append(out, rpcEndpointFromEndpoint(ep))
@ -26,7 +26,7 @@ func rpcEndpointsFromEndpoints(eps []endpoints.Endpoint) *[]*Endpoint {
return &out
}
func rpcEndpointFromEndpoint(ep endpoints.Endpoint) *Endpoint {
func rpcEndpointFromEndpoint(ep endpoint.Endpoint) *Endpoint {
return &Endpoint{
Id: ep.Id().String(),
Name: ep.Name(),