-
Notifications
You must be signed in to change notification settings - Fork 16
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 #2457 from threefoldtech/main_multipletimeservers
support multiple timeservers for the ntpcheck
- Loading branch information
Showing
11 changed files
with
169 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package perf | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/threefoldtech/zbus" | ||
) | ||
|
||
// WithZbusClient adds a zbus.Client to the provided context, returning a new context. | ||
// This allows for the retrieval of the client from the context at a later time. | ||
type zbusClientKey struct{} | ||
|
||
func WithZbusClient(ctx context.Context, client zbus.Client) context.Context { | ||
return context.WithValue(ctx, zbusClientKey{}, client) | ||
} | ||
|
||
// MustGetZbusClient gets zbus client from the given context | ||
func MustGetZbusClient(ctx context.Context) zbus.Client { | ||
return ctx.Value(zbusClientKey{}).(zbus.Client) | ||
} | ||
|
||
// TryGetZbusClient tries to get zbus client from the given context | ||
func TryGetZbusClient(ctx context.Context) (zbus.Client, error) { | ||
zcl, ok := ctx.Value(zbusClientKey{}).(zbus.Client) | ||
if !ok { | ||
return zcl, fmt.Errorf("context does not have zbus client") | ||
} | ||
return zcl, 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