Skip to content
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

Wrapper classes necessary? #4

Open
lewismj opened this issue Oct 28, 2017 · 0 comments
Open

Wrapper classes necessary? #4

lewismj opened this issue Oct 28, 2017 · 0 comments

Comments

@lewismj
Copy link

lewismj commented Oct 28, 2017

If you define a set of implicit definitions for things like Reducer, Initializer ... e.g.

  implicit def toReducer[V](f: (V,V) => V): Reducer[V] = (v1,v2) => f(v1,v2)
  implicit def toInitializer[VA](f: () => VA): Initializer[VA] = () => f()
  implicit def toAggregator[K,V,VA](f: (K,V,VA) => VA): Aggregator[K,V,VA] = (k,v,va) => f(k,v,va)

Then you can just define Rich equivalents:

 implicit class RichTable[K,V](kt: KTable[K,V]) {
    def to(topic: String, f: (K,V,Int) => Int)(implicit ks: Serde[K], vs: Serde[V]): Unit = kt.to(ks,vs,f,topic)
    def through(topic: String, storeName: String)(implicit ks: Serde[K], vs: Serde[V]): KTable[K,V]
      = kt.through(ks,vs,storeName)
  }

I don't think you wouldn't have to redefine all the functions provided by KTable, KStream, etc...
The Rich classes could contain just those functions for which you want to make the passing of the Serde implicit. There wouldn't be a need to introduce ...S objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant