Skip to content
Snippets Groups Projects

Allow to reset key store and stop key fetching

Merged Malte Bauch requested to merge qkdnm-set-key-store into master
Files
3
@@ -109,29 +109,31 @@ func (qm *ETSI014HTTPQuantumModule) Client() *etsi14ClientImpl.ClientImpl {
}
func (qm *ETSI014HTTPQuantumModule) Initialize() error {
var ctx context.Context
ctx, qm.stopFetch = context.WithCancel(context.Background())
qm.active = true
// start polling keys
if qm.master {
go func() {
restartWaitingTime := time.Duration(2) * time.Minute
ticker := time.NewTicker(restartWaitingTime)
defer ticker.Stop()
// immediately start with the ticker instead of waiting the defined amount
RestartFetchLoop:
for {
select {
case <-ticker.C:
qm.doKeyFetching(ctx)
case <-ctx.Done():
break RestartFetchLoop
if !qm.active {
var ctx context.Context
ctx, qm.stopFetch = context.WithCancel(context.Background())
qm.active = true
// start polling keys
if qm.master {
go func() {
restartWaitingTime := time.Duration(20) * time.Second
ticker := time.NewTicker(restartWaitingTime)
defer ticker.Stop()
// immediately start with the ticker instead of waiting the defined amount
RestartFetchLoop:
for {
select {
case <-ticker.C:
qm.doKeyFetching(ctx)
case <-ctx.Done():
break RestartFetchLoop
}
}
}
}()
}()
}
}
return nil
}
Loading