Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-06-26 14:16:27 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-06-26 14:16:27 +0300
commit389ae3336772c9bbf7cd21f2f6aed262e8ae0357 (patch)
treeebcbff78afafb87cc341784c9839388308f68565 /internal/bootstrap
parente57acd088cf151b6cecc70b5c7812955b3f49c93 (diff)
Praefect: server factory introduction
Introduces server factory for creating gRPC servers. Praefect gRPC server created by separate function and can be reused in tests to check routing. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/1698
Diffstat (limited to 'internal/bootstrap')
-rw-r--r--internal/bootstrap/starter/starter.go7
-rw-r--r--internal/bootstrap/starter/starter_test.go5
2 files changed, 7 insertions, 5 deletions
diff --git a/internal/bootstrap/starter/starter.go b/internal/bootstrap/starter/starter.go
index 7c43781af..a8b7c018c 100644
--- a/internal/bootstrap/starter/starter.go
+++ b/internal/bootstrap/starter/starter.go
@@ -23,7 +23,8 @@ const (
)
var (
- errEmptySchema = errors.New("empty schema can't be used")
+ // ErrEmptySchema signals that the address has no schema in it.
+ ErrEmptySchema = errors.New("empty schema can't be used")
errEmptyAddress = errors.New("empty address can't be used")
)
@@ -36,7 +37,7 @@ func ParseEndpoint(endpoint string) (Config, error) {
parts := strings.Split(endpoint, separator)
if len(parts) != 2 {
- return Config{}, fmt.Errorf("unsupported format: %q", endpoint)
+ return Config{}, fmt.Errorf("unsupported format: %q: %w", endpoint, ErrEmptySchema)
}
if err := verifySchema(parts[0]); err != nil {
@@ -65,7 +66,7 @@ func ComposeEndpoint(schema, address string) (string, error) {
func verifySchema(schema string) error {
switch schema {
case "":
- return errEmptySchema
+ return ErrEmptySchema
case TCP, TLS, Unix:
return nil
default:
diff --git a/internal/bootstrap/starter/starter_test.go b/internal/bootstrap/starter/starter_test.go
index 7347d0e13..c5d84b1f8 100644
--- a/internal/bootstrap/starter/starter_test.go
+++ b/internal/bootstrap/starter/starter_test.go
@@ -2,6 +2,7 @@ package starter
import (
"errors"
+ "fmt"
"testing"
"github.com/stretchr/testify/require"
@@ -110,12 +111,12 @@ func TestParseEndpoint(t *testing.T) {
{
desc: "no schema",
addr: "://127.0.0.1:2306",
- expErr: errEmptySchema,
+ expErr: ErrEmptySchema,
},
{
desc: "bad format",
addr: "127.0.0.1:2306",
- expErr: errors.New(`unsupported format: "127.0.0.1:2306"`),
+ expErr: fmt.Errorf(`unsupported format: "127.0.0.1:2306": %w`, ErrEmptySchema),
},
{
desc: "tcp schema addresses",