Commit Graph

36 Commits

Author SHA1 Message Date
Robert van Gent
ab113bf8d1 wire: allow wire.Value to use values with no parent (i.e., struct fields) (google/go-cloud#596) 2018-11-13 13:16:46 -08:00
Ross Light
c4f6234106 wire: add FAQ section (google/go-cloud#573)
Fixes google/go-cloud#555
Updates google/go-cloud#513
2018-11-13 13:16:46 -08:00
ktr
0a4cc23d20 wire: fix typo in example code (google/go-cloud#560) 2018-11-13 13:16:46 -08:00
Yoichiro Shimizu
b84ad6154f wire/readme: wire.InterfaceValue should not return Foo{} (google/go-cloud#504) 2018-11-13 13:16:46 -08:00
Robert van Gent
be8ecba636 wire: fix error messages for Bind and InterfaceValue when the arg doesn't implement the interface (google/go-cloud#491)
Fixes google/go-cloud#490
2018-11-13 13:16:46 -08:00
Robert van Gent
2c50843322 wire: add an example and document how to use wire with mocks (google/go-cloud#488) 2018-11-13 13:16:46 -08:00
Robert van Gent
32c3dc8578 wire/doc: reformat README.md (google/go-cloud#495) 2018-11-13 13:16:46 -08:00
Robert van Gent
cd32a686b1 wire: Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value (google/go-cloud#322)
* Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value.

* Update guestbook sample to use InterfaceValue where appropriate.

* Remove unnecessary ok := true

* Addressing comments from code review.
2018-11-13 13:16:46 -08:00
Issac Trotts
d870f380dd Wire: fix typo in README: App -> Baz (google/go-cloud#239)
A function called initializeApp was returning a foobarbaz.Baz.
2018-11-13 13:16:45 -08:00
Zachary Romero
0a45f324c7 wire: fix example in the ProvideBaz section (google/go-cloud#229) 2018-11-13 13:16:45 -08:00
Ross Light
1de1d101c7 wire/cmd/wire: rename from gowire (google/go-cloud#217)
@cflewis and @bradfitz were right: drop the "go". It's cleaner.
2018-11-13 13:16:45 -08:00
Ross Light
2943de1153 docs: remove references to vgo (google/go-cloud#206)
We should be instructing users to run stable things, and more
adventurous folks can adapt to use Go modules. I just ran the test suite
locally from a `go get` and it compiled and ran fine.

Updates google/go-cloud#78
Updates google/go-cloud#208
2018-11-13 13:16:45 -08:00
Ross Light
fda05073e3 wire: add best practices for provider set compatibility (google/go-cloud#191) 2018-11-13 13:16:45 -08:00
Ross Light
69b0cf53ad all: move back to github.com/google/go-cloud (google/go-cloud#162)
Reverts changes made in google/go-cloud#120 for google/go-cloud#117
2018-11-13 13:16:45 -08:00
Ross Light
0bf9b3b5dd all: fix docs and examples (google/go-cloud#141)
Most notably, adds examples for the blob package.
2018-11-13 13:16:45 -08:00
Ross Light
338b1da068 wire: store value expressions in package variables (google/go-cloud#135)
The code assigns a local unnecessarily, but this should have no
appreciable effect on semantics, just readability.

Fixes google/go-cloud#104
2018-11-13 13:16:45 -08:00
Ross Light
45a535a0bd all: s/go-cloud/go-x-cloud/ (google/go-cloud#120)
Fixes google/go-cloud#117
2018-11-13 13:16:45 -08:00
Ross Light
cd52d44251 wire: clean up README (google/go-cloud#100)
Summary of changes:

-   Rewrote introduction (fixes google/go-cloud#81).
-   Simplified `go generate` explanation by automatically adding the
    comment line to the output.
-   Removed mentions of Dagger. Wire stands enough on its own now, but
    Dagger's influence lives on in our minds.
-   Moved best practices to bottom and removed provider set grouping
    guidance.
2018-11-13 13:16:45 -08:00
Ross Light
b12449f9e3 wire: build provider map incrementally (google/go-cloud#96)
One small breaking change: a provider set can no longer include an
interface binding to a concrete type that is not being provided
(directly or indirectly) by the provider set. I can't imagine a
reasonable use case for the previous behavior, so this likely will
catch more errors

In terms of operation, binding conflict error messages will now give
much more specific line numbers, since they will be reported closer to
where the problem occurred.

Now that provider sets gather this information, it can be exposed in
the package API. gowire now uses this information instead of
trying to build it itself.

Fixes google/go-cloud#29
2018-11-13 13:16:45 -08:00
Ross Light
b2d47f8fcc wire: allow non-panic version of injector (google/go-cloud#91)
Fixes google/go-cloud#7
2018-11-13 13:16:45 -08:00
Ross Light
6345348d86 wire: rename from Goose (google/go-cloud#59)
Rename Goose to wire, making it more obvious what the package does, and look more like the stdlib.

Fixes google/go-cloud#8
2018-11-13 13:16:45 -08:00
Ross Light
e9a61ba66b goose: require pointer for first argument to goose.Bind (google/go-cloud#31)
Fixes google/go-cloud#15
2018-11-13 13:16:45 -08:00
Ross Light
962288c10a goose: s/Use/Build/
Fixes google/go-cloud#6
2018-11-13 13:16:45 -08:00
Ross Light
10676a814b goose: add goose.Value directive
Subsumes previous usage of goose.Optional.

Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-13 13:16:45 -08:00
Ross Light
235a7d8f80 goose: allow non-injector code to live along with injectors
Previously, goose would ignore declarations in the //+build gooseinject
files that were not injectors. This meant that if you wanted to write
application-specific providers, you would need to place them in a
separate file, away from the goose injectors. This means that a typical
application would have three handwritten files: one for the abstract
business logic, one for the platform-specific providers, one for the
platform-specific injector declarations.

This change allows the two platform-specific files to be merged into
one: the //+build gooseinject file. goose will now copy these
declarations out to goose_gen.go. This requires a bit of hackery, since
the generated file may have different identifiers for the imported
packages, so goose will do some light AST rewriting to address these
cases.

(Historical note: this was the first change made externally, so also in
here are the copyright headers and other housekeeping changes.)

Reviewed-by: Tuo Shan <shantuo@google.com>
Reviewed-by: kokoro <noreply+kokoro@google.com>
2018-11-13 13:15:58 -08:00
Ross Light
f8e446fa17 goose: use marker functions instead of comments
To avoid making this CL too large, I did not migrate the existing goose
comments through the repository.  This will be addressed in a subsequent
CL.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
3345599aaf goose: remove optional directive
This introduces some short-term pain in practice, but I aim to fix that
with the goose.Value directive.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
2044e2213b goose: add struct field injection
This makes options structs and application structs much simpler to
inject.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
ccf63fec5d goose: support provider cleanup functions
Documented and updated appropriate providers to reflect.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
1380f96c06 goose: add interface binding
An interface binding instructs goose that a concrete type should be used
to satisfy a dependency on an interface type. goose could determine this
implicitly, but having an explicit directive makes the provider author's
intent clear and allows different concrete types to satisfy different
smaller interfaces.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
e2c2d40041 gcp: set up goose providers
Obsoletes the demos/goose directory by applying it to the rest of the
tree.

Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:56 -08:00
Ross Light
479a501c08 goose: add optional provider inputs
Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:55 -08:00
Ross Light
cb1853b1af goose: use readable variable names
Names are inferred from types most of the time, but have a fallback for
a non-named type. Names are now also disambiguated from symbols in the
same scope.

Reviewed-by: Tuo Shan <shantuo@google.com>
Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-12 14:09:55 -08:00
Ross Light
34987b6bee goose: use function name as implicit provider set
Single-element provider sets are frequently useful enough to warrant
being a default.  Larger groupings within a package are less frequent.

Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Tuo Shan <shantuo@google.com>
2018-11-12 14:09:55 -08:00
Ross Light
4abf804032 goose: rename module to provider set
It is more descriptive of what it is, as well as avoids confusion with
Go modules in the versioning sense.

Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-12 14:09:55 -08:00
Ross Light
26c8618466 goose: dependency injection proof of concept
See documentation and demo for usage and known limitations.

Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-12 14:09:55 -08:00