Skip to content

Commit

Permalink
Reduce unnecessary ETCD Put operations (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
DuodenumL authored Sep 8, 2021
1 parent a5e6c1d commit b9b2168
Show file tree
Hide file tree
Showing 137 changed files with 295 additions and 219 deletions.
1 change: 1 addition & 0 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/projecteru2/core/auth/simple"
"github.com/projecteru2/core/types"

"google.golang.org/grpc"
)

Expand Down
1 change: 1 addition & 0 deletions auth/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/projecteru2/core/types"

"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
Expand Down
4 changes: 2 additions & 2 deletions auth/simple/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"errors"
"testing"

"github.com/stretchr/testify/assert"

grpcmocks "github.com/projecteru2/core/3rdmocks"

"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
Expand Down
1 change: 1 addition & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
pb "github.com/projecteru2/core/rpc/gen"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)
Expand Down
2 changes: 1 addition & 1 deletion client/interceptor/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"strings"

"github.com/cenkalti/backoff/v4"
"github.com/projecteru2/core/log"

"github.com/cenkalti/backoff/v4"
"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion client/resolver/eru/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/projecteru2/core/client/servicediscovery"
"github.com/projecteru2/core/log"

"github.com/projecteru2/core/types"

"google.golang.org/grpc/resolver"
)

Expand Down
2 changes: 1 addition & 1 deletion client/servicediscovery/eru_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/projecteru2/core/client/interceptor"
"github.com/projecteru2/core/client/utils"
"github.com/projecteru2/core/log"

pb "github.com/projecteru2/core/rpc/gen"
"github.com/projecteru2/core/types"

"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion client/utils/servicepusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"sync"
"time"

"github.com/go-ping/ping"
"github.com/projecteru2/core/log"

"github.com/go-ping/ping"
)

// EndpointPusher pushes endpoints to registered channels if the ep is L3 reachable
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
"os"
"time"

"github.com/pkg/errors"
enginetypes "github.com/projecteru2/core/engine/types"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
)

// BuildImage will build image
Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"io/ioutil"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

enginemocks "github.com/projecteru2/core/engine/mocks"
schedulermocks "github.com/projecteru2/core/scheduler/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/calcium.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"
"testing"

"github.com/pkg/errors"
"github.com/projecteru2/core/cluster"
"github.com/projecteru2/core/discovery"
"github.com/projecteru2/core/discovery/helium"
Expand All @@ -19,6 +18,8 @@ import (
"github.com/projecteru2/core/store/etcdv3"
"github.com/projecteru2/core/store/redis"
"github.com/projecteru2/core/types"

"github.com/pkg/errors"
)

// Calcium implement the cluster
Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/calcium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

schedulermocks "github.com/projecteru2/core/scheduler/mocks"
sourcemocks "github.com/projecteru2/core/source/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/wal"
walmocks "github.com/projecteru2/core/wal/mocks"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

// DummyLock replace lock for testing
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package calcium
import (
"context"

"github.com/pkg/errors"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/resources"
resourcetypes "github.com/projecteru2/core/resources/types"
"github.com/projecteru2/core/strategy"
"github.com/projecteru2/core/types"

"github.com/pkg/errors"
)

// CalculateCapacity calculates capacity
Expand Down
1 change: 1 addition & 0 deletions cluster/calcium/capacity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/strategy"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"context"
"sync"

"github.com/pkg/errors"
"github.com/projecteru2/core/cluster"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
)

// ControlWorkload control workloads status
Expand Down
1 change: 1 addition & 0 deletions cluster/calcium/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
lockmocks "github.com/projecteru2/core/lock/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
4 changes: 2 additions & 2 deletions cluster/calcium/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"

enginemocks "github.com/projecteru2/core/engine/mocks"
lockmocks "github.com/projecteru2/core/lock/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
"sync"
"time"

"github.com/pkg/errors"
"github.com/sanity-io/litter"

"github.com/projecteru2/core/cluster"
enginetypes "github.com/projecteru2/core/engine/types"
"github.com/projecteru2/core/log"
Expand All @@ -18,6 +15,9 @@ import (
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"
"github.com/projecteru2/core/wal"

"github.com/pkg/errors"
"github.com/sanity-io/litter"
)

// CreateWorkload use options to create workloads
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"testing"

"github.com/pkg/errors"
enginemocks "github.com/projecteru2/core/engine/mocks"
enginetypes "github.com/projecteru2/core/engine/types"
lockmocks "github.com/projecteru2/core/lock/mocks"
Expand All @@ -16,6 +15,8 @@ import (
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/wal"
walmocks "github.com/projecteru2/core/wal/mocks"

"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/dissociate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package calcium
import (
"context"

"github.com/pkg/errors"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/store"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
)

// DissociateWorkload dissociate workload from eru, return it resource but not modity it
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/dissociate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"testing"

"github.com/docker/go-units"
lockmocks "github.com/projecteru2/core/lock/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/docker/go-units"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
1 change: 1 addition & 0 deletions cluster/calcium/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
enginemocks "github.com/projecteru2/core/engine/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"io/ioutil"
"sync"

"github.com/pkg/errors"
"github.com/projecteru2/core/engine"
enginetypes "github.com/projecteru2/core/engine/types"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
"golang.org/x/net/context"
)

Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"bytes"
"context"

"github.com/pkg/errors"
"github.com/projecteru2/core/engine"

"github.com/pkg/errors"
)

func (c *Calcium) doHook(
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"sync"

"github.com/pkg/errors"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
)

// RemoveImage remove images
Expand Down
1 change: 1 addition & 0 deletions cluster/calcium/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
enginemocks "github.com/projecteru2/core/engine/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"strconv"
"sync"

"github.com/google/uuid"
"github.com/pkg/errors"

enginetypes "github.com/projecteru2/core/engine/types"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/strategy"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"
"github.com/projecteru2/core/wal"

"github.com/google/uuid"
"github.com/pkg/errors"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

enginemocks "github.com/projecteru2/core/engine/mocks"
enginetypes "github.com/projecteru2/core/engine/types"
lockmocks "github.com/projecteru2/core/lock/mocks"
Expand All @@ -22,6 +19,9 @@ import (
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/wal"
walmocks "github.com/projecteru2/core/wal/mocks"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestRunAndWaitFailedThenWALCommitted(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cluster/calcium/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"sort"
"time"

"github.com/pkg/errors"
"github.com/projecteru2/core/cluster"
"github.com/projecteru2/core/lock"
"github.com/projecteru2/core/log"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

"github.com/pkg/errors"
)

func (c *Calcium) doLock(ctx context.Context, name string, timeout time.Duration) (lock lock.DistributedLock, rCtx context.Context, err error) {
Expand Down
4 changes: 2 additions & 2 deletions cluster/calcium/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"

enginemocks "github.com/projecteru2/core/engine/mocks"
"github.com/projecteru2/core/lock"
lockmocks "github.com/projecteru2/core/lock/mocks"
storemocks "github.com/projecteru2/core/store/mocks"
"github.com/projecteru2/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

Expand Down
Loading

0 comments on commit b9b2168

Please sign in to comment.