Skip to content

Commit

Permalink
Merge pull request #256 from mrpalide/feat/connected-server-type-by-v…
Browse files Browse the repository at this point in the history
…isor

ConnectedServersType condition
  • Loading branch information
mrpalide authored Mar 11, 2024
2 parents 3351bcc + cf24ad8 commit 0ba753f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/dmsg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ func (sc *ClientCallbacks) ensure() {

// Config configures a dmsg client entity.
type Config struct {
MinSessions int
UpdateInterval time.Duration // Duration between discovery entry updates.
Callbacks *ClientCallbacks
ClientType string
MinSessions int
UpdateInterval time.Duration // Duration between discovery entry updates.
Callbacks *ClientCallbacks
ClientType string
ConnectedServersType string
}

// Ensure ensures all config values are set.
Expand Down Expand Up @@ -208,6 +209,18 @@ func (ce *Client) Serve(ctx context.Context) {
if isClosed(ce.done) {
return
}

// Skip dmsg servers without user specific types: official, community, all
if ce.conf.ConnectedServersType == "official" {
if entry.Server.ServerType != "official" {
continue
}
} else if ce.conf.ConnectedServersType == "community" {
if entry.Server.ServerType != "community" {
continue
}
}

// If MinSessions is set to 0 then we connect to all available servers.
// If MinSessions is not 0 AND we have enough sessions, we wait for error or done signal.
if ce.conf.MinSessions != 0 && ce.SessionCount() >= ce.conf.MinSessions {
Expand Down

0 comments on commit 0ba753f

Please sign in to comment.