Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
b3620e2c
Commit
b3620e2c
authored
6 years ago
by
Roshan Patil
Browse files
Options
Downloads
Patches
Plain Diff
http client singleton instance
parent
1ed69b80
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!68
Core dev bto c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
httpclientmdl/httpclientmdl.go
+14
-9
httpclientmdl/httpclientmdl.go
with
14 additions
and
9 deletions
httpclientmdl/httpclientmdl.go
+
14
−
9
View file @
b3620e2c
...
...
@@ -4,23 +4,28 @@ import (
"bytes"
"io/ioutil"
"net/http"
"sync"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/constantmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
)
var
httpClient
*
http
.
Client
var
once
sync
.
Once
// GetHTTPClient This method will return the httpClient object with preconfigured settings
func
GetHTTPClient
()
*
http
.
Client
{
transport
:=
&
http
.
Transport
{
MaxIdleConns
:
constantmdl
.
MAXIDLECONNS
,
MaxIdleConnsPerHost
:
constantmdl
.
MAXIDLECONNSPERHOST
,
IdleConnTimeout
:
constantmdl
.
IDLECONNTIMEOUT
,
}
httpClient
:=
&
http
.
Client
{
Transport
:
transport
,
}
once
.
Do
(
func
()
{
transport
:=
&
http
.
Transport
{
MaxIdleConns
:
constantmdl
.
MAXIDLECONNS
,
MaxIdleConnsPerHost
:
constantmdl
.
MAXIDLECONNSPERHOST
,
IdleConnTimeout
:
constantmdl
.
IDLECONNTIMEOUT
,
}
httpClient
=
&
http
.
Client
{
Transport
:
transport
,
}
})
return
httpClient
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets