mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 07:36:19 +01:00 
			
		
		
		
	initial import
This commit is contained in:
		
							
								
								
									
										5
									
								
								microservices/http-retry/client/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								microservices/http-retry/client/go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
module golang.source-fellows.com/samples/rfc7808/server
 | 
			
		||||
 | 
			
		||||
go 1.13
 | 
			
		||||
 | 
			
		||||
require github.com/hashicorp/go-retryablehttp v0.6.6
 | 
			
		||||
							
								
								
									
										8
									
								
								microservices/http-retry/client/go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								microservices/http-retry/client/go.sum
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
 | 
			
		||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
 | 
			
		||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM=
 | 
			
		||||
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
 | 
			
		||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
			
		||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 | 
			
		||||
							
								
								
									
										21
									
								
								microservices/http-retry/client/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								microservices/http-retry/client/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"log"
 | 
			
		||||
 | 
			
		||||
	"github.com/hashicorp/go-retryablehttp"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	retryClient := retryablehttp.NewClient()
 | 
			
		||||
	retryClient.RetryMax = 10
 | 
			
		||||
 | 
			
		||||
	standardClient := retryClient.StandardClient()
 | 
			
		||||
 | 
			
		||||
	res, err := standardClient.Get("http://localhost:8080/")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal("could not request")
 | 
			
		||||
	}
 | 
			
		||||
	defer res.Body.Close()
 | 
			
		||||
	log.Println(res.Status)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								microservices/http-retry/server/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								microservices/http-retry/server/go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module golang.source-fellows.com/samples/httpretry/server
 | 
			
		||||
 | 
			
		||||
go 1.13
 | 
			
		||||
							
								
								
									
										0
									
								
								microservices/http-retry/server/go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								microservices/http-retry/server/go.sum
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										26
									
								
								microservices/http-retry/server/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								microservices/http-retry/server/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var count int = 0
 | 
			
		||||
 | 
			
		||||
func handleHttp(res http.ResponseWriter, req *http.Request) {
 | 
			
		||||
 | 
			
		||||
	responseStatus := http.StatusInternalServerError
 | 
			
		||||
	if count%4 == 0 {
 | 
			
		||||
		responseStatus = http.StatusOK
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Printf("will return %v\n", responseStatus)
 | 
			
		||||
	res.WriteHeader(responseStatus)
 | 
			
		||||
 | 
			
		||||
	count++
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	http.HandleFunc("/", handleHttp)
 | 
			
		||||
	http.ListenAndServe(":8080", nil)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user