retheviper / AsyncServerExample

A simple sample of async API call to other server by go and kotlin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!

Test

Go

Run Server

$ go run app.go

Non-async call to Kotlin Server

$ curl http://localhost:8800/api/v1/call-kotlin-server

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

Run Server

$ ./gradlew bootRun

Non-async call to Go Server

$ curl http://localhost:8900/api/v1/call-go-server

Async call to Go 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

About

A simple sample of async API call to other server by go and kotlin.

License:MIT License


Languages

Language:Kotlin 56.9%Language:Go 43.1%