Team in Mercari JP / Category Growth, Catalogs • Joined Mercari JP in November 2018. • Go : Experienced about 1 year in coding as the Production Code. • Community : Kubernetes Meetup, Cloud Native Meetup, etc • My current interests: Go, GCP, Kubernetes, Microservices,etc.
call suppression mechanism.” • If your app receive multiple requests for the same resource, sync/singleflight is helpful. ◦ RDB( master data ) ◦ Image file ◦ Lookup IP address ◦ Client Certs • “x/sync/singleflight” is imported by 81 packages (As of Oct 7 2019). ◦ github.com/hashicorp/consul/agent/consul ◦ gopkg.in/ebay/fabio.v1/cert ▪ https://github.com/fabiolb/fabio/blob/master/cert/source.go https://godoc.org/golang.org/x/sync/singleflight?importers
“net/lookup.go”) The spec is a little bit different between internal/singleflight and x/sync/singleflight. • GoDoc - x/sync/singleflight, GoDoc - internal/singleflight Go Sync ( This repository provides Go concurrency primitives in addition to the ones provided by the language and "sync" and "sync/atomic" packages. ) FYI: a trend of singleflight https://github.com/golang/sync
the technical spec in Microservices ◦ Client ▪ Request the API of GetCatalogComponent to Microservice A ▪ To get the recommended Catalog( ID:1 ) ▪ To get Catalog inserted within 1 week. ◦ Microservice A - BFF layer ▪ GetCatalogComponent provides the recommended Catalog(ID:1) and the Catalog inserted within 1 week as a aggregator. • Request to API of GetCatalog to Microservice B • Request to API of ListCatalogs to Microservice B ◦ Microservice B - Database layer ▪ GetCatalog provides Catalog specified by using ID ▪ ListCatalogs provides Catalog specified by using 1 weeks.
• If you need to tune the API that requests the same resource, singleflight will be helpful. • It seems to me that such as BFF in Microservices is easy to apply the use case by using singleflight. • If you have the interests, please check the other use case of other products imported singleflight, https://godoc.org/golang.org/x/sync/singleflight?importers Conclusion