Training Day4 - adithnaveen/swiggy-2020-july GitHub Wiki
net/http take the data from the server and show host a server (GIN)
Go Routine (fork, pthread, thread) - channel - select
Worker
Testing Benchmarking
Google MS Facebook Twitter IBM
W3c they have some recommendation
1xx that the client has made the request 2xx the ack got from the server when successfully done 200 - OK 201 - CREATE 3xx - redirection - 307
4xx - client error - 404 - Page Not Found - 405 - Request Type Mismatch (GET/POST) - 403 - Forbidden 5xx
- server error
- 500 - Internal server error
[{ "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" }]
struct { Title, UserId }
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "userId": 1,
C++/C/Python - fork (Scheduling here called as Preemptive)
.net / Java - Threads
Go - Goroutines - the methods are managed by go routine, there is no hardware intervention, it only software (programmable) - co-operated stack size is growable - shrinkable
class MyJob extends Thread {
public void run(){
System.out.println("hl");
}
}
class Impl {
public static void main(String[] args){
new MyJob().start(); -> will invoke OS for creating a thread
}
}
without go routine
time go run main.go https://golang.org/ -> text/html; charset=utf-8
https://jsonplaceholder.typicode.com/posts -> application/json; charset=utf-8
https://httpbin.org/xml -> application/xml
go run main.go 0.59s user 0.29s system 42% cpu 2.079 total
go run main.go 0.50s user 0.25s system 138% cpu 0.543 total - go routine
go run main.go 0.60s user 0.28s system 61% cpu 1.424 total - wait group
channels Select