-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update eventbridge to kernel v0.20.0 (#80)
* Update eventbridge to kernel v0.20.0 * Examples of sending binary data * Increase test coverage
- Loading branch information
Showing
18 changed files
with
576 additions
and
343 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Copyright (C) 2021 - 2024 Dmitry Kolesnikov | ||
// | ||
// This file may be modified and distributed under the terms | ||
// of the Apache License Version 2.0. See the LICENSE file for details. | ||
// https://github.com/fogfish/swarm | ||
// | ||
|
||
package eventbridge | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"github.com/fogfish/swarm" | ||
"github.com/fogfish/swarm/kernel/encoding" | ||
) | ||
|
||
type Option func(*Client) | ||
|
||
var defs = []Option{WithConfig(), WithEnv()} | ||
|
||
func WithConfig(opts ...swarm.Option) Option { | ||
return func(c *Client) { | ||
config := swarm.NewConfig() | ||
for _, opt := range opts { | ||
opt(&config) | ||
} | ||
|
||
// Mandatory overrides | ||
config.PollFrequency = 5 * time.Microsecond | ||
config.Codec = encoding.NewCodecPacket() | ||
|
||
c.config = config | ||
} | ||
} | ||
|
||
func WithService(service EventBridge) Option { | ||
return func(c *Client) { | ||
c.service = service | ||
} | ||
} | ||
|
||
const EnvEventBridge = "CONFIG_SWARM_EVENT_BRIDGE" | ||
|
||
func WithEnv() Option { | ||
return func(c *Client) { | ||
if val, has := os.LookupEnv(EnvEventBridge); has { | ||
c.bus = val | ||
} | ||
} | ||
} |
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.