swap yoink with fetch
This commit is contained in:
parent
61f56f5e80
commit
b11accab0a
8
main.go
8
main.go
|
@ -103,7 +103,7 @@ func main() {
|
||||||
func refreshLoop(manualRefresh, req chan struct{}, res chan []project) {
|
func refreshLoop(manualRefresh, req chan struct{}, res chan []project) {
|
||||||
ticker := time.NewTicker(time.Second * 3600)
|
ticker := time.NewTicker(time.Second * 3600)
|
||||||
|
|
||||||
yoink := func() []project {
|
fetch := func() []project {
|
||||||
projects := make([]project, len(m.Projects))
|
projects := make([]project, len(m.Projects))
|
||||||
copy(projects, m.Projects)
|
copy(projects, m.Projects)
|
||||||
for i, project := range projects {
|
for i, project := range projects {
|
||||||
|
@ -118,15 +118,15 @@ func refreshLoop(manualRefresh, req chan struct{}, res chan []project) {
|
||||||
return projects
|
return projects
|
||||||
}
|
}
|
||||||
|
|
||||||
projects := yoink()
|
projects := fetch()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
projects = yoink()
|
projects = fetch()
|
||||||
case <-manualRefresh:
|
case <-manualRefresh:
|
||||||
ticker.Reset(time.Second * 3600)
|
ticker.Reset(time.Second * 3600)
|
||||||
projects = yoink()
|
projects = fetch()
|
||||||
case <-req:
|
case <-req:
|
||||||
projectsCopy := make([]project, len(projects))
|
projectsCopy := make([]project, len(projects))
|
||||||
copy(projectsCopy, projects)
|
copy(projectsCopy, projects)
|
||||||
|
|
Loading…
Reference in New Issue