v1.4.0: generic Stream[T] — typed stream messages, drop (T, *Stream, error)
- Stream[T]: Send(v T) type-safe; message type recovered from the instantiated Send signature (reflect has no type-args API) - method signatures reduced to (error), (T, error), (*Stream[T], error); the (T, *Stream, error) first-message form is gone — send it via Send - return T and stream message T now run checkType at bind time (Stream[any] remains the explicit untyped escape hatch) - generated clients: TS onMessage: (data: T); Go <-chan T - fix vacuous panic assertions (fmt.Sprint(nil) -> "<nil>") in hardening/route test catch helpers Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -44,8 +44,8 @@ func (s *TestSvc) Hello(dto TestDto) (string, error) {
|
||||
return "hi " + dto.Name, nil
|
||||
}
|
||||
|
||||
func (s *TestSvc) Count(dto TestDto) (*Stream, error) {
|
||||
st := Stream{}
|
||||
func (s *TestSvc) Count(dto TestDto) (*Stream[string], error) {
|
||||
st := &Stream[string]{}
|
||||
go func() {
|
||||
for i := 0; i < 3; i++ {
|
||||
st.Send(fmt.Sprintf("n%d", i))
|
||||
@@ -53,7 +53,7 @@ func (s *TestSvc) Count(dto TestDto) (*Stream, error) {
|
||||
}
|
||||
st.Close()
|
||||
}()
|
||||
return &st, nil
|
||||
return st, nil
|
||||
}
|
||||
|
||||
func TestCtxBoxInject(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user