Skip to content

Commit

Permalink
user core's client pool lib (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
DuodenumL authored Oct 27, 2021
1 parent cd14ad4 commit 6b8872e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 115 deletions.
12 changes: 9 additions & 3 deletions store/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/projecteru2/agent/types"
"github.com/projecteru2/core/client"
pb "github.com/projecteru2/core/rpc/gen"

"github.com/patrickmn/go-cache"
Expand All @@ -14,7 +15,7 @@ import (

// Store use core to store meta
type Store struct {
clientPool *ClientPool
clientPool *client.Pool
config *types.Config
cache *cache.Cache
}
Expand All @@ -24,7 +25,12 @@ var once sync.Once

// New new a Store
func New(ctx context.Context, config *types.Config) (*Store, error) {
clientPool, err := NewCoreRPCClientPool(ctx, config)
clientPoolConfig := &client.PoolConfig{
EruAddrs: config.Core,
Auth: config.Auth,
ConnectionTimeout: config.GlobalConnectionTimeout,
}
clientPool, err := client.NewCoreRPCClientPool(ctx, clientPoolConfig)
if err != nil {
return nil, err
}
Expand All @@ -34,7 +40,7 @@ func New(ctx context.Context, config *types.Config) (*Store, error) {

// GetClient returns a gRPC client
func (c *Store) GetClient() pb.CoreRPCClient {
return c.clientPool.getClient()
return c.clientPool.GetClient()
}

// Init inits the core store only once
Expand Down
112 changes: 0 additions & 112 deletions store/core/rpcpool.go

This file was deleted.

0 comments on commit 6b8872e

Please sign in to comment.