On Mon, 31 Jul 2017, 18:21 roger peppe, <rogpe...@gmail.com> wrote:

>
> > import hpaInformer informer<v2alpha1.HorizontalPodAutoscaler>
> >
> > myInformer := hpaInformer.New(sharedUnderlyingCacheThing)
>
> So... to me, the implementation of NewHorizontalPodAutoscalerInformer looks
> pretty much exactly like what you've got there, where
> sharedUnderlyingCacheThing
> is the result of cache.NewSharedIndexInformer as called currently in the
> code. That is, that constructor inside the call to NewSharedIndexInformer
> seems a lot like a constructor for sharedUnderlyingCacheThing to me.
> I'm not entirely convinced that generics would make the code much
> cleaner in this case.
>

The duplication I'm thinking about is more the multiple packages, one for
each type being informed on. If the top level informers package, or
function, were templatable by the type being informed on, there would be no
need for the per-type packages. As it stands there is little benefit from
the godocs for each individual informer. The current docs are verbose well
beyond the value they add.


>
> You might want to experiment by refactoring some of that k8s code to use
> generics (using whatever your preferred formulation might be) and see
> what it might look like, and whether it looks significantly
> nicer/simpler/cleaner
> as a result
>

I might look at something for the informers case, but it's worth pointing
out that I was thinking generics could provide a difference API, rather
than a cleaner implementation of the existing one.


> I suspect that it might not look that much different - whether you're using
> type-parametric polymorphism or interfaces, somehow you've got to
> plug the specific code into the generic code, and that existing k8s code
> doesn't look like it has that much redundant boilerplate to it.
>
>   cheers,
>     rog.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to