Skip to content

epy0n0ff/go-http-dispatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-http-dispatcher

CircleCI License

golang http dispatcher

Install

$ go get github.com/epy0n0ff/go-http-dispatcher

Usage

	wg := sync.WaitGroup{}
	lock := sync.RWMutex{}

	// create five worker threads
	d := dispatcher.NewDispatcher(context.Background(), 5)

	resPool := d.Run()
	go func() {
		for {
			select {
			case res := <-resPool:
				resp := <-res
				t.Logf("%v", resp.Err)
				dump, _ := httputil.DumpResponse(resp.Resp, true)
				t.Logf("%s", string(dump))
				wg.Done()
			}
		}
	}()

	for i := 0; i < 10000; i++ {
		wg.Add(1)
		req, _ := http.NewRequest("GET", "http://xxxx", nil)
		// enqueue http.Request to workers
		d.Add(req)
	}
	wg.Wait()

License

Apache 2.0

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages