Skip to content

Commit

Permalink
Fix some minor linter warnings in the membership package
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Mar 24, 2023
1 parent 63b22ca commit 4e2b842
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
20 changes: 10 additions & 10 deletions common/membership/grpc_resolver.go
Expand Up @@ -38,8 +38,8 @@ import (

const grpcResolverScheme = "membership"

// Empty type used to enforce a dependency using fx so that we're guaranteed to have
// initialized the global builder before we use it.
// GRPCResolver is an empty type used to enforce a dependency using fx so that we're guaranteed to have initialized
// the global builder before we use it.
type GRPCResolver struct{}

var (
Expand All @@ -51,8 +51,8 @@ var (
)

func init() {
// This must be called in init to avoid race conditions. We don't have a Monitor yet so
// we'll leave it nil and initialize it with fx.
// This must be called in init to avoid race conditions. We don't have a Monitor yet, so we'll leave it nil and
// initialize it with fx.
resolver.Register(&globalGrpcBuilder)
}

Expand All @@ -73,26 +73,26 @@ func (m *grpcBuilder) Scheme() string {
return grpcResolverScheme
}

func (m *grpcBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
func (m *grpcBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
monitor, ok := m.monitor.Load().(Monitor)
if !ok {
return nil, errors.New("grpc resolver has not been initialized yet")
}
// See MakeURL: the service ends up as the "host" of the parsed URL
service := target.URL.Host
r, err := monitor.GetResolver(primitives.ServiceName(service))
serviceResolver, err := monitor.GetResolver(primitives.ServiceName(service))
if err != nil {
return nil, err
}
resolver := &grpcResolver{
grpcResolver := &grpcResolver{
cc: cc,
r: r,
r: serviceResolver,
notifyCh: make(chan *ChangedEvent, 1),
}
if err := resolver.start(); err != nil {
if err := grpcResolver.start(); err != nil {
return nil, err
}
return resolver, nil
return grpcResolver, nil
}

type grpcResolver struct {
Expand Down
14 changes: 6 additions & 8 deletions common/membership/interfaces.go
Expand Up @@ -77,21 +77,19 @@ type (
}

// ServiceResolver provides membership information for a specific temporal service.
// It can be used to resolve which member host is responsible for serving a given key.
// It can also be used to determine the placement of resources across hosts.
ServiceResolver interface {
// Lookup looks up the host that currently owns the resource identified by the given key.
Lookup(key string) (HostInfo, error)
// AddListener adds a listener which will get notified on the given
// channel, whenever membership changes.
// @name: The name for identifying the listener
// @notifyChannel: The channel on which the caller receives notifications
// AddListener adds a listener which will get notified on the given channel whenever membership changes.
AddListener(name string, notifyChannel chan<- *ChangedEvent) error
// RemoveListener removes a listener for this service.
RemoveListener(name string) error
// MemberCount returns host count in hashring for any particular role
// MemberCount returns the number of known hosts running this service.
MemberCount() int
// Members returns all host addresses in hashring for any particular role
// Members returns all known hosts available for this service.
Members() []HostInfo
// Requests to rebuild the hash ring
// RequestRefresh requests that the membership information be refreshed.
RequestRefresh()
}

Expand Down
2 changes: 1 addition & 1 deletion common/membership/ringpop/hostinfo.go
Expand Up @@ -48,7 +48,7 @@ func (hi *hostInfo) GetAddress() string {

// Identity implements ringpop's Membership interface
func (hi *hostInfo) Identity() string {
// for now we just use the address as the identity
// For now, we just use the address as the identity.
return hi.addr
}

Expand Down
2 changes: 1 addition & 1 deletion common/membership/ringpop/monitor.go
Expand Up @@ -338,7 +338,7 @@ func (rpo *monitor) Stop() {
// WhoAmI returns the address (host:port) and labels for a service
// Ringpop implementation of WhoAmI return the address used by ringpop listener.
// This is different from service address as we register ringpop handlers on a separate port.
// For this reason we need to lookup the port for the service and replace ringpop port with service port before
// For this reason we need to look up the port for the service and replace ringpop port with service port before
// returning HostInfo back.
func (rpo *monitor) WhoAmI() (membership.HostInfo, error) {
address, err := rpo.rp.WhoAmI()
Expand Down
2 changes: 1 addition & 1 deletion common/membership/ringpop/service_resolver.go
Expand Up @@ -292,7 +292,7 @@ func (r *serviceResolver) getReachableMembers() ([]string, error) {
servicePort := r.port

// Each temporal service in the ring should advertise which port it has its gRPC listener
// on via a service label. If we cannot find the label, we will assume that that the
// on via a service label. If we cannot find the label, we will assume that the
// temporal service is listening on the same port that this node is listening on.
servicePortLabel, ok := member.Label(rolePort)
if ok {
Expand Down

0 comments on commit 4e2b842

Please sign in to comment.