33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
// Package daemonrpc calls the daemon's credential-backed repository checks.
|
|
package daemonrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
pb "github.com/samcharles93/archie-core/internal/contracts/daemon/v1"
|
|
"github.com/samcharles93/archie-core/internal/domain/presence"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/rpcidentity"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/rpctls"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/telemetry"
|
|
)
|
|
|
|
type Client struct{ rpc pb.DaemonServiceClient }
|
|
|
|
func Dial(target string, id *rpctls.Identity) (*Client, func(), error) {
|
|
creds, err := id.DialOption(target, presence.Daemon)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
conn, err := grpc.NewClient(target, creds, telemetry.ClientOption())
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
return &Client{rpc: pb.NewDaemonServiceClient(conn)}, func() { _ = conn.Close() }, nil
|
|
}
|
|
|
|
func (c *Client) CheckRepository(ctx context.Context, r *pb.CheckRepositoryRequest) (*pb.CheckRepositoryResponse, error) {
|
|
return c.rpc.CheckRepository(rpcidentity.Outgoing(ctx, presence.UI), r)
|
|
}
|