Comments (4)
What is the purpose of this? I don't immediately get it
from connect-go.
Imagine your organization (like Buf!) has a standard collection of options that you'd like every handler, client, or both to use. Without this, you end up with a fairly unpleasant set of APIs: StandardClientOptions() []connect.ClientOption
, etc., and users are constantly appending to slices and splatting them again.
client, err := NewFooClient(...,
append(someorg.StandardClientOptions(),
SomeSpecificOption(),
SomeOtherOneOffOption(),
)...,
)
With these functions, life's a bit nicer. someorg.StandardClientOptions
can bundle a bunch of options into a single connect.ClientOption
, and the user code ends up like this:
client, err := NewFooClient(...,
someorg.StandardClientOptions(),
someorg.UnusualOption(),
MyOneOffOption(),
)
Ultimately, it's convenient for users to be able to make a single option have multiple effects. More or less, this is the same reason your proposal to build a multi-plugin for protoc/buf is nicer than forcing every tool to take a list of plugins to generate into the same directory.
from connect-go.
Examples from other packages I've worked on:
- https://pkg.go.dev/go.uber.org/[email protected]/zapcore#NewTee
- https://pkg.go.dev/go.uber.org/fx#Options
Both of those options ended up pretty widely used, and the fx
one in particular was a cornerstone of the whole ecosystem.
from connect-go.
I'm not sure this will be as used in the connect world and it just adds to the number of types, but you feel strongly about it and it's fine with me. I might say that WithOptions
confuses me a bit as opposed to something signaling this is a union of options like (and not suggesting this directly) but MultiOption
from connect-go.
Related Issues (20)
- Newz
- connect.CodeOf(nil) returns connect.CodeUnknown which is different to gRPC HOT 2
- Cannot test correct handling of `serverStream.Send` error HOT 6
- Why not return a Trailers-only response other than gRPC-Web? HOT 4
- Support context.Context in BidiStream's Receive() HOT 2
- Connect RPC import path being the Buf-tour path HOT 5
- Provide an ergonomic way to test interceptors HOT 2
- conformance: client often reports "unknown" code instead of a code based on HTTP status HOT 1
- conformance: client sometimes reports incorrect error code for canceled/deadline-exceeded conditions HOT 1
- conformance: Connect GET requests should not allow a body or content-headers HOT 1
- conformance: client does not return correct error code for 409 and 415 HTTP status codes HOT 1
- conformance: client does not validate response content-type HOT 1
- [Question] middleware set context not work in stream rpc HOT 2
- Any non mux router support for connectrpc? HOT 4
- [Question] stream HOT 10
- How can I find out the number of connections to the server in interceptor? HOT 1
- How do I understand sent or recieved message on streaming? HOT 3
- Translate errors grom google.golang.org/error to connect-go/error HOT 1
- [Question] Unary Interceptors does not work for Streams! HOT 1
- [Question] design tradeoffs about including ctx in method argument for generated stream handler
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connect-go.