mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Upgrade to Go 1.7 (#128)
* Upgrade to stdlib context package * Modernized syntax
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
e90a109ed5
commit
3ca137a01c
@@ -1,6 +1,7 @@
|
||||
package mqs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -14,7 +15,6 @@ import (
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/iron-io/functions/api/models"
|
||||
"github.com/iron-io/runner/common"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type BoltDbMQ struct {
|
||||
@@ -104,7 +104,7 @@ func NewBoltMQ(url *url.URL) (*BoltDbMQ, error) {
|
||||
func (mq *BoltDbMQ) Start() {
|
||||
go func() {
|
||||
// It would be nice to switch to a tick-less, next-event Timer based model.
|
||||
for _ = range mq.ticker.C {
|
||||
for range mq.ticker.C {
|
||||
err := mq.db.Update(func(tx *bolt.Tx) error {
|
||||
now := uint64(time.Now().UnixNano())
|
||||
for i := 0; i < 3; i++ {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mqs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"sync"
|
||||
@@ -10,7 +11,6 @@ import (
|
||||
"github.com/google/btree"
|
||||
"github.com/iron-io/functions/api/models"
|
||||
"github.com/iron-io/runner/common"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type MemoryMQ struct {
|
||||
@@ -59,7 +59,7 @@ func NewMemoryMQ() *MemoryMQ {
|
||||
func (mq *MemoryMQ) start() {
|
||||
// start goroutine to check for delayed jobs and put them onto regular queue when ready
|
||||
go func() {
|
||||
for _ = range mq.Ticker.C {
|
||||
for range mq.Ticker.C {
|
||||
ji := &TaskItem{
|
||||
StartAt: time.Now(),
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func (mq *MemoryMQ) start() {
|
||||
// start goroutine to check for messages that have timed out and put them back onto regular queue
|
||||
// TODO: this should be like the delayed messages above. Could even be the same thing as delayed messages, but remove them if job is completed.
|
||||
go func() {
|
||||
for _ = range mq.Ticker.C {
|
||||
for range mq.Ticker.C {
|
||||
ji := &TaskItem{
|
||||
StartAt: time.Now(),
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package mqs
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/iron-io/functions/api/models"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type Mock struct {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mqs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/iron-io/functions/api/models"
|
||||
"github.com/iron-io/runner/common"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type RedisMQ struct {
|
||||
@@ -162,7 +162,7 @@ func (mq *RedisMQ) start() {
|
||||
logrus.WithError(err).Fatal("Could not start redis MQ reservation system")
|
||||
}
|
||||
|
||||
for _ = range mq.ticker.C {
|
||||
for range mq.ticker.C {
|
||||
mq.processPendingReservations(conn)
|
||||
mq.processDelayedTasks(conn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user