-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #361 from streamdal/blinktag/relay_fixes
Relay Fixes
- Loading branch information
Showing
13 changed files
with
194 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package actions | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/batchcorp/plumber-schemas/build/go/protos/opts" | ||
|
||
"github.com/batchcorp/plumber/server/types" | ||
) | ||
|
||
func (a *Actions) UpdateConnection(_ context.Context, connectionID string, connOpts *opts.ConnectionOptions) (*types.Connection, error) { | ||
|
||
conn := &types.Connection{Connection: connOpts} | ||
|
||
// Update connection in persistent config | ||
a.cfg.PersistentConfig.SetConnection(connectionID, conn) | ||
_ = a.cfg.PersistentConfig.Save() | ||
|
||
// Starting/stopping needs to lock this mutex, so copy it for access | ||
a.cfg.PersistentConfig.RelaysMutex.RLock() | ||
relays := make(map[string]*types.Relay) | ||
for k, v := range a.cfg.PersistentConfig.Relays { | ||
relays[k] = v | ||
} | ||
a.cfg.PersistentConfig.RelaysMutex.RUnlock() | ||
|
||
// Restart all relays that use this connection and are active | ||
// Inactive relays will pick up the new connection details whenever they get resumed | ||
for _, relay := range relays { | ||
if relay.Options.ConnectionId == connectionID && relay.Active { | ||
// Don't use the request context, use a fresh one | ||
if _, err := a.StopRelay(context.Background(), relay.Options.XRelayId); err != nil { | ||
a.log.Errorf("unable to stop relay '%s': %s", relay.Options.XRelayId, err) | ||
continue | ||
} | ||
|
||
// Don't use the request context, use a fresh one | ||
if _, err := a.ResumeRelay(context.Background(), relay.Options.XRelayId); err != nil { | ||
a.log.Errorf("unable to resume relay '%s': %s", relay.Options.XRelayId, err) | ||
continue | ||
} | ||
} | ||
} | ||
|
||
return conn, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.