Git Product home page Git Product logo

Comments (6)

vangent avatar vangent commented on May 3, 2024 17

Another idea is to have wire.Subtract be a wire directive, used to wrap a ProviderSet in a wire.NewSet or a wire.Build.

Use cases might be:

  1. I want to make a Set AB that unions 2 other sets A and B, but there's a type T that's the same between A and B.
var SetAB = wire.NewSet(A, B)
  • Today, you'd get an error that there's two providers for T and you'd be kind of hosed.
  • With wire.Subtract, you could do:
var SetAB = wire.NewSet(A, wire.Subtract(B, T))
  1. I want to use an existing ProviderSet, but want to override one of the types it provides. For example, azureblob defines a Set that has NewPipeline and Options{} in it. Today, this code would produce an error because Options is provided twice, once by the injector function parameter and once by azureblob.Set.
func azureBucket(bucketName string, opts *azureblob.Options) *blob.Bucket {
  wire.Build(
    azureblob.DefaultIdentity,
    azureblob.Set,
  )

Again, you'd be kind of hosed; you'd have to explicitly add all of the providers in azureblob.Set that you need. With wire.Subtract, you would do:

func azureBucket(bucketName string, opts *azureblob.Options) *blob.Bucket {
  wire.Build(
    azureblob.DefaultIdentity,
    wire.Subtract(azureblob.Set, azureblob.Options),
  )

from wire.

jayzhuang avatar jayzhuang commented on May 3, 2024 2

wire.Subtract sounds good, I'm happy to help review and merge a PR (new owner here :D)

from wire.

michaellee8 avatar michaellee8 commented on May 3, 2024 1

@zombiezen Any chance this will be worked on? Will a PR be accepted if I implement this? This one seems useful for mocking purpose for me.

from wire.

vangent avatar vangent commented on May 3, 2024 1

@eliben can you add the new owners for this repo?

from wire.

giautm avatar giautm commented on May 3, 2024

I have same issue here, Just want to change the timeout value in the default server's driver. :(

from wire.

zombiezen avatar zombiezen commented on May 3, 2024

This seems reasonable to me, but I haven't been working on Wire for a while. @vangent, WDYT?

from wire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.