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

Moved to using a generic map instead of generated maps #1419

Merged
merged 3 commits into from
Feb 14, 2023
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

golangci-lint:
uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main
with:
linter-version: v1.51.1

exclude-fmt-errorf:
uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
run:
# concurrency: 6
go: "1.17"
go: "1.19"
timeout: 2m
issues-exit-code: 1
tests: true
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/benbjohnson/clock v1.3.0
github.com/edwarnicke/exechelper v1.0.2
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29
github.com/edwarnicke/grpcfd v1.1.2
github.com/edwarnicke/serialize v1.0.7
github.com/fsnotify/fsnotify v1.5.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL/xmC5w=
github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs=
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29 h1:4/2wgileNvQB4HfJbq7u4FFLKIfc38a6P0S/51ZGgX8=
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29/go.mod h1:3m+ZfVq+z0pTLW798jmqnifMsalrVLIKmfXaMFvqSuc=
github.com/edwarnicke/grpcfd v1.1.2 h1:2b8kCABQ1+JjSKGDoHadqSW7whCeTXMqtyo6jmB5B8k=
github.com/edwarnicke/grpcfd v1.1.2/go.mod h1:rHihB9YvNMixz8rS+ZbwosI2kj65VLkeyYAI2M+/cGA=
github.com/edwarnicke/serialize v0.0.0-20200705214914-ebc43080eecf/go.mod h1:XvbCO/QGsl3X8RzjBMoRpkm54FIAZH5ChK2j+aox7pw=
Expand Down
5 changes: 3 additions & 2 deletions pkg/networkservice/common/begin/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2022 Cisco and/or its affiliates.
// Copyright (c) 2021-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -19,6 +19,7 @@ package begin
import (
"context"

"github.com/edwarnicke/genericsync"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/pkg/errors"
"google.golang.org/grpc"
Expand All @@ -30,7 +31,7 @@ import (
)

type beginClient struct {
clientMap
genericsync.Map[string, *eventFactoryClient]
}

// NewClient - creates a new begin chain element
Expand Down
75 changes: 0 additions & 75 deletions pkg/networkservice/common/begin/client_map.gen.go

This file was deleted.

31 changes: 0 additions & 31 deletions pkg/networkservice/common/begin/gen.go

This file was deleted.

5 changes: 3 additions & 2 deletions pkg/networkservice/common/begin/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2022 Cisco and/or its affiliates.
// Copyright (c) 2021-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -19,6 +19,7 @@ package begin
import (
"context"

"github.com/edwarnicke/genericsync"
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/pkg/errors"
"google.golang.org/protobuf/types/known/emptypb"
Expand All @@ -29,7 +30,7 @@ import (
)

type beginServer struct {
serverMap
genericsync.Map[string, *eventFactoryServer]
}

// NewServer - creates a new begin chain element
Expand Down
75 changes: 0 additions & 75 deletions pkg/networkservice/common/begin/server_map.gen.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/networkservice/common/externalips/gen.go

This file was deleted.

11 changes: 7 additions & 4 deletions pkg/networkservice/common/externalips/server.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,6 +24,7 @@ import (
"net"
"sync/atomic"

"github.com/edwarnicke/genericsync"
"github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/empty"
"github.com/networkservicemesh/api/pkg/api/networkservice"
Expand Down Expand Up @@ -59,8 +62,8 @@ func NewServer(chainCtx context.Context, options ...Option) networkservice.Netwo
result := &externalIPsServer{
chainCtx: chainCtx,
}
result.externalToInternalMap.Store(new(stringMap))
result.internalToExternalMap.Store(new(stringMap))
result.externalToInternalMap.Store(new(genericsync.Map[string, string]))
result.internalToExternalMap.Store(new(genericsync.Map[string, string]))
for _, o := range options {
o(result)
}
Expand All @@ -86,7 +89,7 @@ func NewServer(chainCtx context.Context, options ...Option) networkservice.Netwo
}

func replaceFunc(v atomic.Value) func(ip net.IP) net.IP {
m := v.Load().(*stringMap)
m := v.Load().(*genericsync.Map[string, string])
return func(ip net.IP) net.IP {
key := ip.String()
value, _ := m.Load(key)
Expand All @@ -109,7 +112,7 @@ func (e *externalIPsServer) build(ips map[string]string) error {
return err
}
}
internalIPs, externalIPs := new(stringMap), new(stringMap)
internalIPs, externalIPs := new(genericsync.Map[string, string]), new(genericsync.Map[string, string])
for k, v := range ips {
internalIPs.Store(k, v)
externalIPs.Store(v, k)
Expand Down
Loading