Skip to content

Commit 6a72a0b

Browse files
committed
Allow a custom HTTP client to be used with ServiceReservation
Signed-off-by: Chris Harris <cjh@lbl.gov>
1 parent 89c5e11 commit 6a72a0b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pkg/service-reservations/interface.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ type ServiceReservation interface {
9797

9898
InitInstance(stateManagerServer string, reservationPath string, defaultTermMinutes int, logger *logrus.Logger, svcName string)
9999

100+
//Initialize with a custom http client (for example with OAuth2 transport)
101+
InitWithHTTPClient(stateManagerServer string, reservationPath string, defaultTermMinutes int, logger *logrus.Logger, svcName string, httpClient *retryablehttp.Client)
102+
100103
//Try to aquire locks for a list of xnames, renewing them within 30 seconds of expiration.
101104
Aquire(xnames []string) error
102105

@@ -179,6 +182,12 @@ func (i *Production) InitInstance(stateManagerServer string, reservationPath str
179182
i.Init(stateManagerServer, reservationPath, defaultTermMinutes, logger)
180183
}
181184

185+
// Initialize with a custom http client (for example with OAuth2 transport)
186+
func (i *Production) InitWithHTTPClient(stateManagerServer string, reservationPath string, defaultTermMinutes int, logger *logrus.Logger, svcName string, httpClient *retryablehttp.Client) {
187+
i.InitInstance(stateManagerServer, reservationPath, defaultTermMinutes, logger, svcName)
188+
i.httpClient = httpClient
189+
}
190+
182191
// Lets make this really simple; Im going to wake up and see what expires in the next 30 seconds;
183192
// then I will renew those things
184193
func (i *Production) doRenewal() {

0 commit comments

Comments
 (0)