Skip to content

Commit

Permalink
fix: address typo (#468)
Browse files Browse the repository at this point in the history
* fix: typo change adder to addr

Signed-off-by: Bowser1704 <bowser1704@gmail.com>
  • Loading branch information
Bowser1704 authored Jul 20, 2021
1 parent fc3d65c commit 11acf4f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/daemon/service/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (m *manager) CheckHealth(context.Context) error {
func (m *manager) Download(ctx context.Context,
req *dfdaemongrpc.DownRequest, results chan<- *dfdaemongrpc.DownResult) error {
m.Keep()
// init peer task request, peer download request uses different peer id
// init peer task request, peer uses different peer id to generate every request
peerTask := &peer.FilePeerTaskRequest{
PeerTaskRequest: scheduler.PeerTaskRequest{
Url: req.Url,
Expand Down
10 changes: 5 additions & 5 deletions pkg/rpc/cdnsystem/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
"google.golang.org/grpc"
)

func GetClientByAddr(adders []dfnet.NetAddr, opts ...grpc.DialOption) (CdnClient, error) {
if len(adders) == 0 {
func GetClientByAddr(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (CdnClient, error) {
if len(addrs) == 0 {
return nil, errors.New("address list of cdn is empty")
}
cc := &cdnClient{
rpc.NewConnection(context.Background(), "cdn", adders, []rpc.ConnOption{
rpc.NewConnection(context.Background(), "cdn", addrs, []rpc.ConnOption{
rpc.WithConnExpireTime(60 * time.Second),
rpc.WithDialOption(opts),
}),
Expand All @@ -46,7 +46,7 @@ func GetClientByAddr(adders []dfnet.NetAddr, opts ...grpc.DialOption) (CdnClient
var once sync.Once
var elasticCdnClient *cdnClient

func GetElasticClientByAdders(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (CdnClient, error) {
func GetElasticClientByAddrs(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (CdnClient, error) {
once.Do(func() {
elasticCdnClient = &cdnClient{
rpc.NewConnection(context.Background(), "cdn-elastic", make([]dfnet.NetAddr, 0), []rpc.ConnOption{
Expand All @@ -68,7 +68,7 @@ type CdnClient interface {

GetPieceTasks(ctx context.Context, addr dfnet.NetAddr, req *base.PieceTaskRequest, opts ...grpc.CallOption) (*base.PiecePacket, error)

UpdateState(adders []dfnet.NetAddr)
UpdateState(addrs []dfnet.NetAddr)

Close() error
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ func WithDialTimeout(dialTimeout time.Duration) ConnOption {
})
}

func NewConnection(ctx context.Context, name string, adders []dfnet.NetAddr, connOpts []ConnOption) *Connection {
func NewConnection(ctx context.Context, name string, addrs []dfnet.NetAddr, connOpts []ConnOption) *Connection {
conn := newDefaultConnection(ctx)
conn.name = name
addresses := make([]string, 0, len(adders))
for _, addr := range adders {
addresses := make([]string, 0, len(addrs))
for _, addr := range addrs {
addresses = append(addresses, addr.GetEndpoint())
}
conn.hashRing = hashring.New(addresses)
conn.serverNodes = adders
conn.serverNodes = addrs
for _, opt := range connOpts {
opt.apply(conn)
}
Expand Down Expand Up @@ -409,11 +409,11 @@ func (conn *Connection) Close() error {
return nil
}

func (conn *Connection) UpdateState(adders []dfnet.NetAddr) {
func (conn *Connection) UpdateState(addrs []dfnet.NetAddr) {
// todo lock
conn.serverNodes = adders
conn.serverNodes = addrs
var addresses []string
for _, addr := range adders {
for _, addr := range addrs {
addresses = append(addresses, addr.GetEndpoint())
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/dfdaemon/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func GetClientByAddr(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (DaemonClie
var once sync.Once
var elasticDaemonClient *daemonClient

func GetElasticClientByAdders(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (DaemonClient, error) {
func GetElasticClientByAddrs(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (DaemonClient, error) {
once.Do(func() {
elasticDaemonClient = &daemonClient{
rpc.NewConnection(context.Background(), "daemon-elastic", make([]dfnet.NetAddr, 0), []rpc.ConnOption{
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/dfdaemon/client/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func GetPieceTasks(ctx context.Context, destPeer *scheduler.PeerPacket_DestPeer,

func getClient(netAddr dfnet.NetAddr, toCdn bool) (rpc.Closer, error) {
if toCdn {
return cdnclient.GetElasticClientByAdders([]dfnet.NetAddr{netAddr})
return cdnclient.GetElasticClientByAddrs([]dfnet.NetAddr{netAddr})
}
return GetElasticClientByAdders([]dfnet.NetAddr{netAddr})
return GetElasticClientByAddrs([]dfnet.NetAddr{netAddr})
}

0 comments on commit 11acf4f

Please sign in to comment.