Files
seaweedfs/weed/parquet_pushdown/daemon/filer_client.go
T
Chris Lu e181e2c035 parquet_pushdown(M0-C3): daemon bootstrap (config, filer client, server)
Add weed/parquet_pushdown/daemon, the host process for the
SeaweedParquetPushdown service:

- Config carries bind ip/port, filer addresses, trust mode, and the
  ConnectorTrustedAck flag that gates the dev-only connector-trusted
  trust mode (default refuses it; explicit ack required).
- filerClient probes the filer with GetFilerConfiguration at startup
  so bad endpoints fail fast, mirroring the iam command's pattern.
  Bounded by a 60s timeout; later milestones use the same client to
  read Parquet data and side-index blobs.
- server.go wires it together: load TLS, probe filer, build the
  Service, listen on (host, localhost) gRPC ports, register the
  service + reflection on each, install grace.OnInterrupt for
  GracefulStop, and Serve.

Run() returns an error so the calling weed pushdown command can
report startup failures instead of glog.Fatalf.
2026-04-25 13:40:45 -07:00

49 lines
1.5 KiB
Go

package daemon
import (
"context"
"fmt"
"time"
"google.golang.org/grpc"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)
// filerClient is a thin handle around the daemon's filer endpoints.
// M0 only uses it to confirm filer reachability at startup; later
// milestones add read paths for Parquet data and side-index blobs.
type filerClient struct {
addresses []pb.ServerAddress
grpcDialOption grpc.DialOption
}
func newFilerClient(addresses []pb.ServerAddress, grpcDialOption grpc.DialOption) *filerClient {
return &filerClient{addresses: addresses, grpcDialOption: grpcDialOption}
}
// waitUntilReachable blocks until the daemon can complete a
// GetFilerConfiguration RPC against any of its configured filer
// addresses, or the context is cancelled. Mirrors the iam command's
// startup-time filer probe.
func (c *filerClient) waitUntilReachable(ctx context.Context) error {
for {
err := pb.WithOneOfGrpcFilerClients(false, c.addresses, c.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
_, getErr := client.GetFilerConfiguration(ctx, &filer_pb.GetFilerConfigurationRequest{})
return getErr
})
if err == nil {
glog.V(0).Infof("pushdown daemon connected to filers %v", c.addresses)
return nil
}
glog.V(0).Infof("pushdown daemon waiting for filers %v: %v", c.addresses, err)
select {
case <-ctx.Done():
return fmt.Errorf("filer reachability wait cancelled: %w", ctx.Err())
case <-time.After(time.Second):
}
}
}