TL; DR

Async API call example by goroutine and coroutine.

Tested with Go 1.16.15 & Java 11.

Go server uses Gin and Kotlin server uses Spring Boot.

Concept

Some API takes 5 second to process, and each server need to call the API for 10 times.

So, call it by async!

Run

Go

Run server

$ go run app.go

Async call to Kotlin Server

# with no cap
$ curl http://localhost:8800/api/v1/call-kotlin-server-async

# with cap(2)
$ curl http://localhost:8800/api/v1/call-kotlin-server-async-dual

Kotlin Server

$ ./gradlew bootRun

Async call to Kotlin Server

# with no cap
$ curl http://localhost:8900/api/v1/call-go-server-async

# with cap(2)
$ curl http://localhost:8900/api/v1/call-go-server-async-dual

GitHub

View Github