Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Prepare v2 #26

Merged
merged 42 commits into from
Nov 27, 2019
Merged

Prepare v2 #26

merged 42 commits into from
Nov 27, 2019

Conversation

defval
Copy link
Owner

@defval defval commented Nov 21, 2019

Massive refactoring and rethinking features.

Remove

  • Replacing (need investigating)
  • Combined providers such what they are [need investigating]
  • No functional provider types [for more strict interface]

Change

  • Graph implementation [need to add styles]

Add

  • Prototype providing
  • Clean function
  • Embed parameters
  • Increase code readability
  • Low-level container interface

@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #26 into master will decrease coverage by 4.51%.
The diff coverage is 93.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
- Coverage   98.19%   93.67%   -4.52%     
==========================================
  Files          13       26      +13     
  Lines         442      712     +270     
==========================================
+ Hits          434      667     +233     
- Misses          5       39      +34     
- Partials        3        6       +3
Impacted Files Coverage Δ
di/internal/ditest/incorrect.go 0% <0%> (ø)
di/internal/dag/output.go 0% <0%> (ø)
di/internal/dag/edge.go 100% <100%> (ø)
di/internal/ditest/qux.go 100% <100%> (ø)
di/internal/reflection/reflection.go 100% <100%> (ø)
di/internal/ditest/baz.go 100% <100%> (ø)
di/internal/ditest/fooer_group.go 100% <100%> (ø)
di/internal/reflection/iface.go 100% <100%> (ø)
options.go 100% <100%> (ø) ⬆️
di/parameter.go 100% <100%> (ø)
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be6cefd...bfb340c. Read the comment docs.

@defval
Copy link
Owner Author

defval commented Nov 21, 2019

@maxzhang1985 Hello! I'm preparing a v2 release.
I implement inject.Prototype() option that is doing what you wanted.
If you have time, you can check how correctly I understand you.

With this option, the provider creates a new instance of type by each extraction.

Test for checking it:

package inject_test

import (
	"fmt"
	"net/http"
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/defval/inject"
)

// NewHTTPServer
func NewHTTPServer() *http.Server {
	return &http.Server{}
}

func TestPrototype(t *testing.T) {
	container := inject.New(
		inject.Provide(NewHTTPServer, inject.Prototype()),
	)

	var server1 *http.Server
	require.NoError(t, container.Extract(&server1))

	var server2 *http.Server
	require.NoError(t, container.Extract(&server2))

	require.NotEqual(t, fmt.Sprintf("%p", server1), fmt.Sprintf("%p", server2))
}

@defval defval added the enhancement New feature or request label Nov 21, 2019
@defval defval added this to the v2 milestone Nov 21, 2019
@yoyofx
Copy link

yoyofx commented Nov 22, 2019

@defval Yes , this is what I needed!

@defval defval mentioned this pull request Nov 26, 2019
@defval defval merged commit 3a01569 into master Nov 27, 2019
@defval defval deleted the v2 branch December 6, 2019 15:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants