Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
dea4edff
Commit
dea4edff
authored
Jul 03, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'use-contexts' into 'master'
Use http.Request contexts for Gitaly calls See merge request !179
parents
fadf660e
2b93db7a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
29 deletions
+17
-29
internal/git/blob.go
internal/git/blob.go
+1
-1
internal/git/info-refs.go
internal/git/info-refs.go
+3
-6
internal/git/receive-pack.go
internal/git/receive-pack.go
+4
-3
internal/git/upload-pack.go
internal/git/upload-pack.go
+4
-3
internal/gitaly/commit.go
internal/gitaly/commit.go
+2
-6
internal/gitaly/smarthttp.go
internal/gitaly/smarthttp.go
+3
-10
No files found.
internal/git/blob.go
View file @
dea4edff
...
...
@@ -44,7 +44,7 @@ func handleSendBlobWithGitaly(w http.ResponseWriter, r *http.Request, params *bl
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"commit.GetBlob: %v"
,
err
))
}
if
err
:=
commitClient
.
SendBlob
(
w
,
&
params
.
TreeEntryRequest
);
err
!=
nil
{
if
err
:=
commitClient
.
SendBlob
(
r
.
Context
(),
w
,
&
params
.
TreeEntryRequest
);
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"commit.GetBlob: %v"
,
err
))
}
}
...
...
internal/git/info-refs.go
View file @
dea4edff
package
git
import
(
"context"
"fmt"
"io"
"net/http"
...
...
@@ -8,8 +9,6 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/gitaly"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"golang.org/x/net/context"
)
func
GetInfoRefsHandler
(
a
*
api
.
API
)
http
.
Handler
{
...
...
@@ -35,7 +34,7 @@ func handleGetInfoRefs(rw http.ResponseWriter, r *http.Request, a *api.Response)
if
a
.
GitalyServer
.
Address
==
""
{
err
=
handleGetInfoRefsLocally
(
w
,
a
,
rpc
)
}
else
{
err
=
handleGetInfoRefsWithGitaly
(
w
,
a
,
rpc
)
err
=
handleGetInfoRefsWithGitaly
(
r
.
Context
(),
w
,
a
,
rpc
)
}
if
err
!=
nil
{
...
...
@@ -64,14 +63,12 @@ func handleGetInfoRefsLocally(w http.ResponseWriter, a *api.Response, rpc string
return
nil
}
func
handleGetInfoRefsWithGitaly
(
w
http
.
ResponseWriter
,
a
*
api
.
Response
,
rpc
string
)
error
{
func
handleGetInfoRefsWithGitaly
(
ctx
context
.
Context
,
w
http
.
ResponseWriter
,
a
*
api
.
Response
,
rpc
string
)
error
{
smarthttp
,
err
:=
gitaly
.
NewSmartHTTPClient
(
a
.
GitalyServer
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"GetInfoRefsHandler: %v"
,
err
)
}
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
infoRefsResponseReader
,
err
:=
smarthttp
.
InfoRefsResponseReader
(
ctx
,
&
a
.
Repository
,
rpc
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"GetInfoRefsHandler: %v"
,
err
)
...
...
internal/git/receive-pack.go
View file @
dea4edff
package
git
import
(
"context"
"fmt"
"io"
"net/http"
...
...
@@ -23,7 +24,7 @@ func handleReceivePack(w *GitHttpResponseWriter, r *http.Request, a *api.Respons
if
a
.
GitalyServer
.
Address
==
""
{
err
=
handleReceivePackLocally
(
a
,
r
,
cr
,
cw
,
action
)
}
else
{
err
=
handleReceivePackWithGitaly
(
a
,
cr
,
cw
)
err
=
handleReceivePackWithGitaly
(
r
.
Context
(),
a
,
cr
,
cw
)
}
return
err
...
...
@@ -45,13 +46,13 @@ func handleReceivePackLocally(a *api.Response, r *http.Request, stdin io.Reader,
return
nil
}
func
handleReceivePackWithGitaly
(
a
*
api
.
Response
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
func
handleReceivePackWithGitaly
(
ctx
context
.
Context
,
a
*
api
.
Response
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
smarthttp
,
err
:=
gitaly
.
NewSmartHTTPClient
(
a
.
GitalyServer
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"smarthttp.ReceivePack: %v"
,
err
)
}
if
err
:=
smarthttp
.
ReceivePack
(
&
a
.
Repository
,
a
.
GL_ID
,
a
.
GL_REPOSITORY
,
clientRequest
,
clientResponse
);
err
!=
nil
{
if
err
:=
smarthttp
.
ReceivePack
(
ctx
,
&
a
.
Repository
,
a
.
GL_ID
,
a
.
GL_REPOSITORY
,
clientRequest
,
clientResponse
);
err
!=
nil
{
return
fmt
.
Errorf
(
"smarthttp.ReceivePack: %v"
,
err
)
}
...
...
internal/git/upload-pack.go
View file @
dea4edff
package
git
import
(
"context"
"fmt"
"io"
"net/http"
...
...
@@ -30,7 +31,7 @@ func handleUploadPack(w *GitHttpResponseWriter, r *http.Request, a *api.Response
if
a
.
GitalyServer
.
Address
==
""
{
err
=
handleUploadPackLocally
(
a
,
r
,
buffer
,
w
,
action
)
}
else
{
err
=
handleUploadPackWithGitaly
(
a
,
buffer
,
w
)
err
=
handleUploadPackWithGitaly
(
r
.
Context
(),
a
,
buffer
,
w
)
}
return
err
...
...
@@ -57,13 +58,13 @@ func handleUploadPackLocally(a *api.Response, r *http.Request, stdin *os.File, s
return
nil
}
func
handleUploadPackWithGitaly
(
a
*
api
.
Response
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
func
handleUploadPackWithGitaly
(
ctx
context
.
Context
,
a
*
api
.
Response
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
smarthttp
,
err
:=
gitaly
.
NewSmartHTTPClient
(
a
.
GitalyServer
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"smarthttp.UploadPack: %v"
,
err
)
}
if
err
:=
smarthttp
.
UploadPack
(
&
a
.
Repository
,
clientRequest
,
clientResponse
);
err
!=
nil
{
if
err
:=
smarthttp
.
UploadPack
(
ctx
,
&
a
.
Repository
,
clientRequest
,
clientResponse
);
err
!=
nil
{
return
fmt
.
Errorf
(
"smarthttp.UploadPack: %v"
,
err
)
}
...
...
internal/gitaly/commit.go
View file @
dea4edff
package
gitaly
import
(
"context"
"fmt"
"io"
"net/http"
...
...
@@ -8,18 +9,13 @@ import (
pb
"gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/streamio"
"golang.org/x/net/context"
)
type
CommitClient
struct
{
pb
.
CommitClient
}
func
(
client
*
CommitClient
)
SendBlob
(
w
http
.
ResponseWriter
,
request
*
pb
.
TreeEntryRequest
)
error
{
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
func
(
client
*
CommitClient
)
SendBlob
(
ctx
context
.
Context
,
w
http
.
ResponseWriter
,
request
*
pb
.
TreeEntryRequest
)
error
{
c
,
err
:=
client
.
TreeEntry
(
ctx
,
request
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rpc failed: %v"
,
err
)
...
...
internal/gitaly/smarthttp.go
View file @
dea4edff
package
gitaly
import
(
"context"
"fmt"
"io"
pb
"gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/streamio"
"golang.org/x/net/context"
)
type
SmartHTTPClient
struct
{
...
...
@@ -40,10 +39,7 @@ func infoRefsReader(stream infoRefsClient) io.Reader {
})
}
func
(
client
*
SmartHTTPClient
)
ReceivePack
(
repo
*
pb
.
Repository
,
glId
string
,
glRepository
string
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
func
(
client
*
SmartHTTPClient
)
ReceivePack
(
ctx
context
.
Context
,
repo
*
pb
.
Repository
,
glId
string
,
glRepository
string
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
stream
,
err
:=
client
.
PostReceivePack
(
ctx
)
if
err
!=
nil
{
return
err
...
...
@@ -89,10 +85,7 @@ func (client *SmartHTTPClient) ReceivePack(repo *pb.Repository, glId string, glR
return
nil
}
func
(
client
*
SmartHTTPClient
)
UploadPack
(
repo
*
pb
.
Repository
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
ctx
,
cancelFunc
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancelFunc
()
func
(
client
*
SmartHTTPClient
)
UploadPack
(
ctx
context
.
Context
,
repo
*
pb
.
Repository
,
clientRequest
io
.
Reader
,
clientResponse
io
.
Writer
)
error
{
stream
,
err
:=
client
.
PostUploadPack
(
ctx
)
if
err
!=
nil
{
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment