Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tochemey authored Jun 23, 2023
2 parents 03b66cd + 2872dcd commit b9fd5d8
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 422 deletions.
9 changes: 0 additions & 9 deletions .codecov.yml

This file was deleted.

14 changes: 1 addition & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
submodules: false
fetch-depth: 0
# - uses: wagoid/commitlint-github-action@v5.3.0
- uses: wagoid/commitlint-github-action@v5.3.0
- name: Login to GitHub Docker
env:
DOCKER_REGISTRY: ghcr.io
Expand All @@ -37,15 +37,3 @@ jobs:
FORCE_COLOR: 1
run: |
earthly -P -use-inline-cache --save-inline-cache --strict --push +test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
# - uses: go-semantic-release/action@v1
# id: semver
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# allow-initial-development-versions: true
# force-bump-patch-version: true
8 changes: 1 addition & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
submodules: false
fetch-depth: 0
# - uses: wagoid/commitlint-github-action@v5.3.0
- uses: wagoid/commitlint-github-action@v5.3.0
- name: Login to GitHub Docker
env:
DOCKER_REGISTRY: ghcr.io
Expand All @@ -41,9 +41,3 @@ jobs:
FORCE_COLOR: 1
run: |
earthly -P -use-inline-cache --save-inline-cache --strict --push +test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
2 changes: 1 addition & 1 deletion actors/actor_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func NewActorSystem(name string, opts ...Option) (ActorSystem, error) {
system = &actorSystem{
actors: cmp.New[PID](),
hasStarted: atomic.NewBool(false),
typesLoader: NewTypesLoader(nil),
typesLoader: NewTypesLoader(),
clusterChan: make(chan *goaktpb.WireActor, 10),
name: name,
logger: log.DefaultLogger,
Expand Down
3 changes: 1 addition & 2 deletions actors/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const (
)

var (
ErrLocalAddress = errors.New("address is a local address")
ErrRemoteAddress = errors.New("address is a remote address")
ErrLocalAddress = errors.New("address is a local address")
)

// Address represents the physical location under which an Actor can be
Expand Down
4 changes: 2 additions & 2 deletions actors/reflection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestReflection(t *testing.T) {
t.Run("With ActorFrom", func(t *testing.T) {
tl := NewTypesLoader(nil)
tl := NewTypesLoader()
// create an instance of an actor
actor := NewTestActor()
// register the actor into the types registry
Expand All @@ -25,7 +25,7 @@ func TestReflection(t *testing.T) {
})

t.Run("With ActorOf", func(t *testing.T) {
tl := NewTypesLoader(nil)
tl := NewTypesLoader()
// create an instance of an actor
actor := NewTestActor()
// register the actor into the types registry
Expand Down
57 changes: 7 additions & 50 deletions actors/types_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,25 @@ type TypesLoader interface {
Type(v any) (reflect.Type, bool)
// TypeByName returns the type of object given its name
TypeByName(name string) (reflect.Type, bool)
// Parent represents the parent typesLoader
Parent() TypesLoader
}

// typesLoader implements TypesLoader
type typesLoader struct {
parent TypesLoader
names map[string]reflect.Type
types map[string]reflect.Type
mu sync.Mutex
names map[string]reflect.Type
types map[string]reflect.Type
mu sync.Mutex
}

// enforce compilation error
var _ TypesLoader = &typesLoader{}

// NewTypesLoader creates an instance of TypesLoader
func NewTypesLoader(parent TypesLoader) TypesLoader {
func NewTypesLoader() TypesLoader {
l := &typesLoader{
parent: nil,
names: make(map[string]reflect.Type),
types: make(map[string]reflect.Type),
mu: sync.Mutex{},
names: make(map[string]reflect.Type),
types: make(map[string]reflect.Type),
mu: sync.Mutex{},
}
l.SetParent(parent)
return l
}

Expand Down Expand Up @@ -87,13 +82,6 @@ func (l *typesLoader) Type(v any) (reflect.Type, bool) {
path := fmt.Sprintf("%s.%s", vType.PkgPath(), vType.Name())
// lookup the type in the typesLoader registry
t, ok := l.types[path]
// if not found check whether the parent has it
if !ok {
// if the parent is not nil lookup for the type
if l.parent != nil {
return l.parent.Type(v)
}
}
// if ok return it
return t, ok
}
Expand All @@ -107,37 +95,6 @@ func (l *typesLoader) TypeByName(name string) (reflect.Type, bool) {

// grab the type from the existing names
t, ok := l.names[name]
// if not found check with the parent typesLoader
if !ok {
// if the parent is not nil lookup for the type
if l.parent != nil {
return l.parent.TypeByName(name)
}
}
// if ok return it
return t, ok
}

// Parent returns the typesLoader parent
func (l *typesLoader) Parent() TypesLoader {
return l.parent
}

// SetParent sets the typesLoader
func (l *typesLoader) SetParent(parent TypesLoader) {
// check whether the parent is nil
if parent == nil {
return
}

// if the parent is the same as the given typesLoader return
if parent == l {
return
}

// only set when the parent is not nil
if l.parent == nil {
l.parent = parent
return
}
}
7 changes: 3 additions & 4 deletions actors/types_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (

func TestTypesLoader(t *testing.T) {
t.Run("With new instance", func(t *testing.T) {
tl := NewTypesLoader(nil)
tl := NewTypesLoader()
var p any = tl
_, ok := p.(TypesLoader)
assert.True(t, ok)
assert.Nil(t, tl.Parent())
})

t.Run("With registration with name", func(t *testing.T) {
tl := NewTypesLoader(nil)
tl := NewTypesLoader()
// create an instance of an object
actor := NewTestActor()
// register that actor
Expand All @@ -29,7 +28,7 @@ func TestTypesLoader(t *testing.T) {
})

t.Run("With registration without name", func(t *testing.T) {
tl := NewTypesLoader(nil)
tl := NewTypesLoader()
// create an instance of an object
actor := NewTestActor()
// register that actor
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/joho/godotenv v1.5.1
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/client_golang v1.16.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/travisjeffery/go-dynaport v1.0.0
Expand All @@ -33,8 +33,8 @@ require (
go.uber.org/goleak v1.2.1
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/net v0.10.0
google.golang.org/grpc v1.55.0
golang.org/x/net v0.11.0
google.golang.org/grpc v1.56.0
google.golang.org/protobuf v1.30.0
k8s.io/api v0.28.0-alpha.2
k8s.io/apimachinery v0.28.0-alpha.2
Expand All @@ -55,7 +55,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand All @@ -79,7 +79,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -94,13 +94,13 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.opentelemetry.io/proto/otlp v0.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
Expand All @@ -111,7 +111,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230601164746-7562a1006961 // indirect
k8s.io/kube-openapi v0.0.0-20230614213217-ba0abe644833 // indirect
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
Expand Down
Loading

0 comments on commit b9fd5d8

Please sign in to comment.