Mode had exactly one legal value after the previous commit deleted the in-process path, which made it dead config surface that could only confuse an operator into thinking there was still a real choice. ServiceConnection is now just a target address; composeChatContract only checks it's non-blank, defaulting to 127.0.0.1:8585.
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package archied
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/gateway"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
|
)
|
|
|
|
// composeChatContract dials the standalone archie-gateway, the sole owner of
|
|
// ChatContract.
|
|
func composeChatContract(settings config.ServiceConnection, options ...grpc.DialOption) (gateway.ChatContract, func(), error) {
|
|
if strings.TrimSpace(settings.Target) == "" {
|
|
return nil, nil, fmt.Errorf("services.gateway.target is required")
|
|
}
|
|
// Deployments that put the Gateway on a separate trust boundary supply
|
|
// their own transport credentials through options; the default must be
|
|
// usable without manufacturing a certificate in the config loader.
|
|
opts := append([]grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}, options...)
|
|
conn, err := grpc.NewClient(settings.Target, opts...)
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("create gateway client: %w", err)
|
|
}
|
|
return gatewayrpc.NewClient(conn), func() { _ = conn.Close() }, nil
|
|
}
|