本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pfs.NewAPIClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewAPIClient函数的具体用法?Golang NewAPIClient怎么用?Golang NewAPIClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewAPIClient函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getAPIClient
func getAPIClient(address string) (pfs.APIClient, error) {
clientConn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
return nil, err
}
return pfs.NewAPIClient(clientConn), nil
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:7,代码来源:cmds.go
示例2: RunBench
func RunBench(
b *testing.B,
f func(*testing.B, pfs.APIClient),
) {
discoveryClient, err := getEtcdClient()
require.NoError(b, err)
var cluster *cluster
prototest.RunB(
b,
testNumServers,
func(servers map[string]*grpc.Server) {
cluster = registerFunc(b, discoveryClient, servers)
},
func(b *testing.B, clientConns map[string]*grpc.ClientConn) {
var clientConn *grpc.ClientConn
for _, c := range clientConns {
clientConn = c
break
}
go func() {
require.Equal(b, cluster.realSharder.AssignRoles(cluster.cancel), shard.ErrCancelled)
}()
cluster.WaitForAvailability()
f(
b,
pfs.NewAPIClient(
clientConn,
),
)
},
)
cluster.Shutdown()
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:33,代码来源:testing.go
示例3: getPfsClient
func getPfsClient(tb testing.TB) pfs.APIClient {
pfsdAddr := os.Getenv("PFSD_PORT_650_TCP_ADDR")
if pfsdAddr == "" {
tb.Error("PFSD_PORT_650_TCP_ADDR not set")
}
clientConn, err := grpc.Dial(fmt.Sprintf("%s:650", pfsdAddr), grpc.WithInsecure())
require.NoError(tb, err)
return pfs.NewAPIClient(clientConn)
}
开发者ID:angelabier1,项目名称:pachyderm,代码行数:9,代码来源:testing_test.go
示例4: getOnce
func (m *mounterProvider) getOnce() (Mounter, error) {
clientConn, err := grpc.Dial(m.pfsAddress, grpc.WithInsecure())
if err != nil {
return nil, err
}
return NewMounter(
pfs.NewAPIClient(
clientConn,
),
), nil
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:11,代码来源:mounter_provider.go
示例5: do
func do(appEnvObj interface{}) error {
appEnv := appEnvObj.(*appEnv)
containerClient, err := getContainerClient()
if err != nil {
return err
}
rethinkAPIClient, err := getRethinkAPIClient(appEnv.DatabaseAddress, appEnv.DatabaseName)
if err != nil {
return err
}
pfsdAddress, err := getPfsdAddress()
if err != nil {
return err
}
clientConn, err := grpc.Dial(pfsdAddress, grpc.WithInsecure())
if err != nil {
return err
}
pfsAPIClient := pfs.NewAPIClient(clientConn)
jobAPIServer := jobserver.NewAPIServer(
pfsAPIClient,
rethinkAPIClient,
containerClient,
appEnv.PfsMountDir,
jobserverrun.JobRunnerOptions{
RemoveContainers: appEnv.RemoveContainers,
},
)
jobAPIClient := pps.NewLocalJobAPIClient(jobAPIServer)
pipelineAPIServer := pipelineserver.NewAPIServer(pfsAPIClient, jobAPIClient, rethinkAPIClient)
errC := make(chan error)
go func() {
errC <- protoserver.Serve(
uint16(appEnv.Port),
func(s *grpc.Server) {
pps.RegisterJobAPIServer(s, jobAPIServer)
pps.RegisterPipelineAPIServer(s, pipelineAPIServer)
},
protoserver.ServeOptions{
DebugPort: uint16(appEnv.DebugPort),
Version: pachyderm.Version,
},
)
}()
// TODO: pretty sure without this there is a problem, this is bad, we would
// prefer a callback for when the server is ready to accept requests
time.Sleep(1 * time.Second)
if err := pipelineAPIServer.Start(); err != nil {
return err
}
return <-errC
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:52,代码来源:main.go
示例6: do
func do(appEnvObj interface{}) error {
appEnv := appEnvObj.(*appEnv)
rethinkAPIClient, err := getRethinkAPIClient(appEnv.DatabaseAddress, appEnv.DatabaseName)
if err != nil {
return err
}
pfsdAddress, err := getPfsdAddress()
if err != nil {
return err
}
clientConn, err := grpc.Dial(pfsdAddress, grpc.WithInsecure())
if err != nil {
return err
}
pfsAPIClient := pfs.NewAPIClient(clientConn)
kubeAddr, err := getKubeAddress()
if err != nil {
return err
}
config := &kube.Config{
Host: kubeAddr,
Insecure: true,
}
kubeClient, err := kube.New(config)
if err != nil {
protolog.Printf("Error creating kubernetes client: %s", err.Error())
}
jobAPIServer := jobserver.NewAPIServer(
pfsAPIClient,
rethinkAPIClient,
kubeClient,
)
jobAPIClient := pps.NewLocalJobAPIClient(jobAPIServer)
pipelineAPIServer := pipelineserver.NewAPIServer(pfsAPIClient, jobAPIClient, rethinkAPIClient)
if err := pipelineAPIServer.Start(); err != nil {
return err
}
return protoserver.Serve(
uint16(appEnv.Port),
func(s *grpc.Server) {
pps.RegisterJobAPIServer(s, jobAPIServer)
pps.RegisterInternalJobAPIServer(s, jobAPIServer)
pps.RegisterPipelineAPIServer(s, pipelineAPIServer)
},
protoserver.ServeOptions{
DebugPort: uint16(appEnv.DebugPort),
Version: pachyderm.Version,
},
)
}
开发者ID:klucar,项目名称:pachyderm,代码行数:50,代码来源:main.go
示例7: DeleteCommit
func (a *apiServer) DeleteCommit(ctx context.Context, request *pfs.DeleteCommitRequest) (*google_protobuf.Empty, error) {
a.versionLock.RLock()
defer a.versionLock.RUnlock()
ctx = versionToContext(a.version, ctx)
clientConns, err := a.router.GetAllClientConns(a.version)
if err != nil {
return nil, err
}
for _, clientConn := range clientConns {
if _, err := pfs.NewAPIClient(clientConn).DeleteCommit(ctx, request); err != nil {
return nil, err
}
}
return google_protobuf.EmptyInstance, nil
}
开发者ID:mehulsbhatt,项目名称:pachyderm,代码行数:15,代码来源:api_server.go
示例8: getPfsClient
func (a *apiServer) getPfsClient() (pfs.APIClient, error) {
if a.pfsAPIClient == nil {
var onceErr error
a.pfsClientOnce.Do(func() {
clientConn, err := grpc.Dial(a.pfsAddress, grpc.WithInsecure())
if err != nil {
onceErr = err
}
a.pfsAPIClient = pfs.NewAPIClient(clientConn)
})
if onceErr != nil {
return nil, onceErr
}
}
return a.pfsAPIClient, nil
}
开发者ID:jnevin,项目名称:pachyderm,代码行数:16,代码来源:api_server.go
示例9: do
func do(appEnvObj interface{}) error {
appEnv := appEnvObj.(*appEnv)
rethinkAPIServer, err := getRethinkAPIServer(appEnv.DatabaseAddress, appEnv.DatabaseName)
if err != nil {
return err
}
pfsdAddress, err := getPfsdAddress()
if err != nil {
return err
}
clientConn, err := grpc.Dial(pfsdAddress, grpc.WithInsecure())
if err != nil {
return err
}
pfsAPIClient := pfs.NewAPIClient(clientConn)
kubeClient, err := getKubeClient()
if err != nil {
return err
}
jobAPIServer := jobserver.NewAPIServer(
pfsAPIClient,
rethinkAPIServer,
kubeClient,
)
jobAPIClient := pps.NewLocalJobAPIClient(jobAPIServer)
pipelineAPIServer := pipelineserver.NewAPIServer(pfsAPIClient, jobAPIClient, rethinkAPIServer)
if err := pipelineAPIServer.Start(); err != nil {
return err
}
return protoserver.Serve(
uint16(appEnv.Port),
func(s *grpc.Server) {
pps.RegisterJobAPIServer(s, jobAPIServer)
pps.RegisterInternalJobAPIServer(s, jobAPIServer)
pps.RegisterPipelineAPIServer(s, pipelineAPIServer)
},
protoserver.ServeOptions{
DebugPort: uint16(appEnv.DebugPort),
Version: pachyderm.Version,
},
)
}
开发者ID:alamehor,项目名称:pachyderm,代码行数:42,代码来源:main.go
示例10: TestWriteAndRead
func TestWriteAndRead(t *testing.T) {
t.Parallel()
// don't leave goroutines running
var wg sync.WaitGroup
defer wg.Wait()
tmp, err := ioutil.TempDir("", "pachyderm-test-")
if err != nil {
t.Fatalf("tempdir: %v", err)
}
defer func() {
if err := os.RemoveAll(tmp); err != nil {
t.Errorf("cannot remove tempdir: %v", err)
}
}()
// closed on successful termination
quit := make(chan struct{})
defer close(quit)
listener, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("cannot listen: %v", err)
}
defer func() {
_ = listener.Close()
}()
// TODO try to share more of this setup code with various main
// functions
localAddress := listener.Addr().String()
srv := grpc.NewServer()
const (
numShards = 1
)
sharder := shard.NewLocalSharder(localAddress, numShards)
hasher := pfs.NewHasher(numShards, 1)
router := shard.NewRouter(
sharder,
grpcutil.NewDialer(
grpc.WithInsecure(),
),
localAddress,
)
blockDir := filepath.Join(tmp, "blocks")
blockServer, err := server.NewLocalBlockAPIServer(blockDir)
if err != nil {
t.Fatalf("NewLocalBlockAPIServer: %v", err)
}
pfs.RegisterBlockAPIServer(srv, blockServer)
driver, err := drive.NewDriver(localAddress)
if err != nil {
t.Fatalf("NewDriver: %v", err)
}
apiServer := server.NewAPIServer(
hasher,
router,
)
pfs.RegisterAPIServer(srv, apiServer)
internalAPIServer := server.NewInternalAPIServer(
hasher,
router,
driver,
)
pfs.RegisterInternalAPIServer(srv, internalAPIServer)
wg.Add(1)
go func() {
defer wg.Done()
if err := srv.Serve(listener); err != nil {
select {
case <-quit:
// orderly shutdown
return
default:
t.Errorf("grpc serve: %v", err)
}
}
}()
clientConn, err := grpc.Dial(localAddress, grpc.WithInsecure())
if err != nil {
t.Fatalf("grpc dial: %v", err)
}
apiClient := pfs.NewAPIClient(clientConn)
mounter := fuse.NewMounter(localAddress, apiClient)
mountpoint := filepath.Join(tmp, "mnt")
if err := os.Mkdir(mountpoint, 0700); err != nil {
t.Fatalf("mkdir mountpoint: %v", err)
}
ready := make(chan bool)
wg.Add(1)
go func() {
defer wg.Done()
//.........这里部分代码省略.........
开发者ID:tv42,项目名称:pachyderm,代码行数:101,代码来源:filesystem_test.go
示例11: TestCommitFinishedReadDir
func TestCommitFinishedReadDir(t *testing.T) {
t.Parallel()
// don't leave goroutines running
var wg sync.WaitGroup
defer wg.Wait()
tmp, err := ioutil.TempDir("", "pachyderm-test-")
if err != nil {
t.Fatalf("tempdir: %v", err)
}
defer func() {
if err := os.RemoveAll(tmp); err != nil {
t.Errorf("cannot remove tempdir: %v", err)
}
}()
// closed on successful termination
quit := make(chan struct{})
defer close(quit)
listener, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("cannot listen: %v", err)
}
defer func() {
_ = listener.Close()
}()
// TODO try to share more of this setup code with various main
// functions
localAddress := listener.Addr().String()
srv := grpc.NewServer()
const (
numShards = 1
)
sharder := shard.NewLocalSharder(localAddress, numShards)
hasher := pfs.NewHasher(numShards, 1)
router := shard.NewRouter(
sharder,
grpcutil.NewDialer(
grpc.WithInsecure(),
),
localAddress,
)
blockDir := filepath.Join(tmp, "blocks")
blockServer, err := server.NewLocalBlockAPIServer(blockDir)
if err != nil {
t.Fatalf("NewLocalBlockAPIServer: %v", err)
}
pfs.RegisterBlockAPIServer(srv, blockServer)
driver, err := drive.NewDriver(localAddress)
if err != nil {
t.Fatalf("NewDriver: %v", err)
}
apiServer := server.NewAPIServer(
hasher,
router,
)
pfs.RegisterAPIServer(srv, apiServer)
internalAPIServer := server.NewInternalAPIServer(
hasher,
router,
driver,
)
pfs.RegisterInternalAPIServer(srv, internalAPIServer)
wg.Add(1)
go func() {
defer wg.Done()
if err := srv.Serve(listener); err != nil {
select {
case <-quit:
// orderly shutdown
return
default:
t.Errorf("grpc serve: %v", err)
}
}
}()
clientConn, err := grpc.Dial(localAddress, grpc.WithInsecure())
if err != nil {
t.Fatalf("grpc dial: %v", err)
}
apiClient := pfs.NewAPIClient(clientConn)
mounter := fuse.NewMounter(localAddress, apiClient)
mountpoint := filepath.Join(tmp, "mnt")
if err := os.Mkdir(mountpoint, 0700); err != nil {
t.Fatalf("mkdir mountpoint: %v", err)
}
ready := make(chan bool)
wg.Add(1)
go func() {
defer wg.Done()
//.........这里部分代码省略.........
开发者ID:tv42,项目名称:pachyderm,代码行数:101,代码来源:filesystem_test.go
示例12: TestRootReadDir
func TestRootReadDir(t *testing.T) {
t.Parallel()
// don't leave goroutines running
var wg sync.WaitGroup
defer wg.Wait()
tmp, err := ioutil.TempDir("", "pachyderm-test-")
if err != nil {
t.Fatalf("tempdir: %v", err)
}
defer func() {
if err := os.RemoveAll(tmp); err != nil {
t.Errorf("cannot remove tempdir: %v", err)
}
}()
// closed on successful termination
quit := make(chan struct{})
defer close(quit)
listener, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("cannot listen: %v", err)
}
defer func() {
_ = listener.Close()
}()
// TODO try to share more of this setup code with various main
// functions
localAddress := listener.Addr().String()
srv := grpc.NewServer()
const (
numShards = 1
)
sharder := shard.NewLocalSharder(localAddress, numShards)
hasher := pfs.NewHasher(numShards, 1)
router := shard.NewRouter(
sharder,
grpcutil.NewDialer(
grpc.WithInsecure(),
),
localAddress,
)
blockDir := filepath.Join(tmp, "blocks")
blockServer, err := server.NewLocalBlockAPIServer(blockDir)
if err != nil {
t.Fatalf("NewLocalBlockAPIServer: %v", err)
}
pfs.RegisterBlockAPIServer(srv, blockServer)
driver, err := drive.NewDriver(localAddress)
if err != nil {
t.Fatalf("NewDriver: %v", err)
}
apiServer := server.NewAPIServer(
hasher,
router,
)
pfs.RegisterAPIServer(srv, apiServer)
internalAPIServer := server.NewInternalAPIServer(
hasher,
router,
driver,
)
pfs.RegisterInternalAPIServer(srv, internalAPIServer)
wg.Add(1)
go func() {
defer wg.Done()
if err := srv.Serve(listener); err != nil {
select {
case <-quit:
// orderly shutdown
return
default:
t.Errorf("grpc serve: %v", err)
}
}
}()
clientConn, err := grpc.Dial(localAddress, grpc.WithInsecure())
if err != nil {
t.Fatalf("grpc dial: %v", err)
}
apiClient := pfs.NewAPIClient(clientConn)
mounter := fuse.NewMounter(localAddress, apiClient)
mountpoint := filepath.Join(tmp, "mnt")
if err := os.Mkdir(mountpoint, 0700); err != nil {
t.Fatalf("mkdir mountpoint: %v", err)
}
ready := make(chan bool)
wg.Add(1)
go func() {
defer wg.Done()
//.........这里部分代码省略.........
开发者ID:tv42,项目名称:pachyderm,代码行数:101,代码来源:filesystem_test.go
示例13: NewAPIClient
func NewAPIClient(cc *grpc.ClientConn) *APIClient {
return &APIClient{
pfs.NewAPIClient(cc),
pps.NewAPIClient(cc),
}
}
开发者ID:tv42,项目名称:pachyderm,代码行数:6,代码来源:pachyderm.go
注:本文中的github.com/pachyderm/pachyderm/src/pfs.NewAPIClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论