-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redefine stream types #61
Comments
Actually, on the client side we can make this work by using 'type =': type MyInputJobStream = boost.JobStream[MyInput]
type MyOutputJobStream = boost.OutputStream[MyOutput] with these in place, we can now do: pool.Start(context.Background(),
make(MyOutputJobStream),
) ... and this works because of the '=', which doesn't introduce new types, they introduce aliases to existing type, which makes them compatible, so now MyOutputJobStream is compatible with boost.OutputStream[MyOutput] This is a good lesson. Perhaps this should be emphasized in documentation. |
so now, the purpose of this issue changes from redefining the core channel types to changing the way these types are interacted with. |
The stream types have the Job embedded within them. Due to the design of go types, this gives us a problem that somethimes make working with the types difficult to understand.
If it were easy to translated between related types (specifically the channel types), we wouldn't have a problem.
Eg
If we have input and output types defined as:
we can define out work pool as:
But the problem here is, if we try to use the predefined channel definitions, we find that incompatibles occur, as the type keyword introduces new incompatible types.
So, using OutputStream
.. is ok in isolation, but when we consider this:
this only works with:
when in actual fact, we would rather use our custom channel type defs:
which is not valid, due to incompatible types:
cannot use make(MyOutputJobStream) (value of type MyOutputJobStream) as boost.OutputStream[MyOutput] value in argument to pool.Startcompiler[InvalidChanAssign](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#InvalidChanAssign)
So MyOutputJobStream is not compatible with boost.OutputStream[MyOutput]
The text was updated successfully, but these errors were encountered: