Skip to content
Chris Lu edited this page Oct 24, 2015 · 3 revisions

Use struct

Many other systems favors a database-oriented row/column approach when dealing with data. However, it loosens the type information.

It's totally fine to use the struct.

  type Product struct{
    Id    int
    Name  string
  }
  type Rating struct{
    ProductId    int
    Score        int
  }

  productChan := make(chan Product)
  ratingChan := make(chan Rating)

  f := flow.New()
  prod := f.Channel(productChan).Map(func(p Product) (int, Product){
    return p.Id, p
  })
  rating := f.Channel(ratingChan).Map(func(r Rating) (int, Rating){
    return r.ProductId, r
  })
  prod.Join(rating).Map(func(id int, p Product, r Rating) {
    ...
  })



Clone this wiki locally