Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STStore & STScheduler improvements #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion changelogs/0.6.1.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 0.6.1

- Depends on `wireleap/common` v0.3.7.
- Depends on `wireleap/common` v0.3.8.
- New feature, API REST interface:
- Support for TCP port and Unix socket
- Status endpoint exposing basic telemetry on `/api/status`
- Most of JSON files have indentation disabled, to reduce their size.
- STStore malformed files handling
- STStore & STScheduler expiration handling

- Uses interfaces:

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.16
require (
github.com/blang/semver v3.5.1+incompatible
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2
github.com/wireleap/common v0.3.7
github.com/wireleap/common v0.3.8
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2 h1:t8KYCwSKsOEZBFELI4Pn/phbp38iJ1RRAkDFNin1aak=
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/wireleap/common v0.3.7 h1:Z2Z/bcVmcTxdzsTUtAAZLP+LwcpJ4oH0CXgEVRm58aI=
github.com/wireleap/common v0.3.7/go.mod h1:bL+o0kyAOn+4ZCtAlWY3YvKhxztfXoA//BFOvqKOsgI=
github.com/wireleap/common v0.3.8 h1:OYqrbBc2U6KEC65yLsCb/x8g4zA0BjscmUDGz5QpeqQ=
github.com/wireleap/common v0.3.8/go.mod h1:bL+o0kyAOn+4ZCtAlWY3YvKhxztfXoA//BFOvqKOsgI=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand Down
10 changes: 9 additions & 1 deletion stscheduler/stscheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type T struct {
tt *time.Ticker
}

func New(dur time.Duration, submit func(*sharetoken.T) error) (t *T) {
func New(dur time.Duration, submit func(*sharetoken.T) error, expire func(*sharetoken.T) error) (t *T) {
t = &T{
tt: time.NewTicker(dur),
scheduled: map[int64][]*sharetoken.T{},
Expand All @@ -38,6 +38,14 @@ func New(dur time.Duration, submit func(*sharetoken.T) error) (t *T) {

if st.IsExpiredAt(ntime.Unix()) {
// next attempt will fail
if errX := expire(st); errX != nil {
log.Printf(
"could not expire failed sharetoken (sig=%s): %s",
st.Signature,
errX,
)
}

blurb = "next submission attempt is past submission window! skipping sharetoken"
} else {
// try again later
Expand Down
2 changes: 1 addition & 1 deletion sub/startcmd/startcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func serverun(fm fsdir.T) {
)
}
return nil
})
}, sts.Exp)

// schedule tokens in store for submission on startup
for _, st := range sts.Filter("", "") {
Expand Down