• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fogfish / swarm / 16241430889

12 Jul 2025 07:43PM UTC coverage: 59.549% (+1.2%) from 58.352%
16241430889

push

github

web-flow
swarm kernel v0.23.0 (#126)

* swarm kernel v0.23.0
* preemptive emitter loop without loss of emission
* improve retry and timeout handling in kernel
* re:enable configurable backoff strategy
* refactor kernel api for better developer experience
* update unit tests with centralised mock
* broadcaster utility

182 of 239 new or added lines in 11 files covered. (76.15%)

2 existing lines in 1 file now uncovered.

1163 of 1953 relevant lines covered (59.55%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.65
/kernel/factory.go
1
//
2
// Copyright (C) 2021 - 2024 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the Apache License Version 2.0. See the LICENSE file for details.
6
// https://github.com/fogfish/swarm
7
//
8

9
package kernel
10

11
import (
12
        "os"
13
        "sync"
14

15
        "github.com/fogfish/swarm"
16
        "github.com/fogfish/swarm/kernel/broadcast"
17
)
18

19
var (
20
        sysf *factory
21
        once sync.Once
22
)
23

24
func builder() *factory {
1✔
25
        once.Do(func() {
2✔
26
                sysf = &factory{}
1✔
27
                sysf.setup()
1✔
28
        })
1✔
29

30
        return sysf
1✔
31
}
32

33
type factory struct {
34
        // messaging kernel is running in the externally preemptable mode
35
        isExternallyPreemptable bool
36

37
        ctrlPreempt *broadcast.Broadcaster
38
}
39

40
func (b *factory) setup() {
1✔
41
        if _, has := os.LookupEnv("AWS_LAMBDA_FUNCTION_NAME"); has {
1✔
NEW
42
                b.enableExternalPreemption()
×
NEW
43
        }
×
44
}
45

NEW
46
func (b *factory) enableExternalPreemption() {
×
NEW
47
        b.isExternallyPreemptable = true
×
NEW
48
        b.ctrlPreempt = broadcast.New()
×
NEW
49
}
×
50

51
func (b *factory) Bridge(cfg swarm.Config) *Bridge {
1✔
52
        bridge := newBridge(cfg)
1✔
53
        bridge.ctrlPreempt = b.ctrlPreempt
1✔
54

1✔
55
        return bridge
1✔
56
}
1✔
57

58
func (b *factory) Emitter(emitter Emitter, cfg swarm.Config) *EmitterCore {
1✔
59
        enqueuer := newEmitter(emitter, cfg)
1✔
60
        enqueuer.ctrlPreempt = b.ctrlPreempt
1✔
61

1✔
62
        return enqueuer
1✔
63
}
1✔
64

65
func (b *factory) Listener(cathode Listener, config swarm.Config) *ListenerCore {
1✔
66
        dequeuer := newListener(cathode, config)
1✔
67

1✔
68
        return dequeuer
1✔
69
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc