Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
erokhinav committed Dec 5, 2024
1 parent 1134055 commit 15d2e41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions liteapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ type Options struct {
LiteServers []config.LiteServer
Timeout time.Duration
// MaxConnections specifies a number of connections to lite servers for a connections pool.
MaxConnections int
NumPerConnection int
MaxConnections int
WorkersPerConnection int
// InitCtx is used when opening a new connection to lite servers during the initialization.
InitCtx context.Context
// ProofPolicy specifies a policy for proof checks.
Expand Down Expand Up @@ -115,9 +115,9 @@ func WithMaxConnectionsNumber(maxConns int) Option {
}
}

func WithNumPerConnection(numPerConn int) Option {
func WithWorkersPerConnection(workersNum int) Option {
return func(o *Options) error {
o.NumPerConnection = numPerConn
o.WorkersPerConnection = workersNum
return nil
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ func NewClient(options ...Option) (*Client, error) {
DetectArchiveNodes: false,
SyncConnectionsInitialization: true,
PoolStrategy: pool.BestPingStrategy,
NumPerConnection: 1,
WorkersPerConnection: 1,
}
for _, o := range options {
if err := o(opts); err != nil {
Expand All @@ -288,7 +288,7 @@ func NewClient(options ...Option) (*Client, error) {
return nil, fmt.Errorf("server list empty")
}
connPool := pool.New(opts.PoolStrategy)
initCh := connPool.InitializeConnections(opts.InitCtx, opts.Timeout, opts.MaxConnections, opts.NumPerConnection, opts.DetectArchiveNodes, opts.LiteServers)
initCh := connPool.InitializeConnections(opts.InitCtx, opts.Timeout, opts.MaxConnections, opts.WorkersPerConnection, opts.DetectArchiveNodes, opts.LiteServers)
if opts.SyncConnectionsInitialization {
if err := <-initCh; err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions liteapi/pool/conn_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ func New(strategy Strategy) *ConnPool {
}
}

func (p *ConnPool) InitializeConnections(ctx context.Context, timeout time.Duration, maxConnections int, numPerConnection int, detectArchiveNodes bool, servers []config.LiteServer) chan error {
func (p *ConnPool) InitializeConnections(ctx context.Context, timeout time.Duration, maxConnections int, workersPerConnection int, detectArchiveNodes bool, servers []config.LiteServer) chan error {
ch := make(chan error, 1)
go func() {
clientsCh := make(chan clientWrapper, len(servers))
for connID, server := range servers {
go func(connID int, server config.LiteServer) {
cli, _ := connect(ctx, timeout, server, numPerConnection)
cli, _ := connect(ctx, timeout, server, workersPerConnection)
// TODO: log error
clientsCh <- clientWrapper{
connID: connID,
Expand Down Expand Up @@ -128,7 +128,7 @@ func connect(ctx context.Context, timeout time.Duration, server config.LiteServe
if err != nil {
return nil, err
}
cli := liteclient.NewClient(c, liteclient.OptionTimeout(timeout), liteclient.OptionConnectionsNum(n))
cli := liteclient.NewClient(c, liteclient.OptionTimeout(timeout), liteclient.OptionWorkersPerConnection(n))
if _, err := cli.LiteServerGetMasterchainInfo(ctx); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion liteclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func OptionTimeout(t time.Duration) Options {
}
}

func OptionConnectionsNum(n int) Options {
func OptionWorkersPerConnection(n int) Options {
return func(c *Client) {
if n < 1 {
n = 1
Expand Down

0 comments on commit 15d2e41

Please sign in to comment.