Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
1c2bfc99
Commit
1c2bfc99
authored
Feb 27, 2019
by
John Cai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add development documentation for gitaly feature flags
parent
12818c20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
doc/development/gitaly.md
doc/development/gitaly.md
+79
-0
No files found.
doc/development/gitaly.md
View file @
1c2bfc99
...
...
@@ -191,3 +191,82 @@ as a [CI environment variable](../ci/variables/README.md#variables).
---
[
Return to Development documentation
](
README.md
)
## Wrapping RPCs in Feature Flags
Here are the steps to gate a new feature in Gitaly behind a feature flag.
### Gitaly
1.
Create a package scoped flag name:
```
go
var
findAllTagsFeatureFlag
=
"go-find-all-tags"
```
1.
Create a switch in the code using the
`featureflag`
package:
```
go
if
featureflag
.
IsEnabled
(
ctx
,
findAllTagsFeatureFlag
)
{
// go implementation
}
else
{
// ruby implementation
}
```
1.
Create prometheus metrics:
```
go
var
findAllTagsRequests
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"gitaly_find_all_tags_requests_total"
,
Help
:
"Counter of go vs ruby implementation of FindAllTags"
,
},
[]
string
{
"implementation"
},
)
)
func
init
()
{
prometheus
.
Register
(
findAllTagsRequests
)
}
if
featureflag
.
IsEnabled
(
ctx
,
findAllTagsFeatureFlag
)
{
findAllTagsRequests
.
WithLabelValues
(
"go"
)
.
Inc
()
// go implementation
}
else
{
findAllTagsRequests
.
WithLabelValues
(
"ruby"
)
.
Inc
()
// ruby impelmentation
}
```
1.
Set headers in tests:
```
go
import
(
"google.golang.org/grpc/metadata"
"gitlab.com/gitlab-org/gitaly/internal/featureflag"
)
//...
md
:=
metadata
.
New
(
map
[
string
]
string
{
featureflag
.
HeaderKey
(
findAllTagsFeatureFlag
)
:
"true"
})
ctx
=
metadata
.
NewOutgoingContext
(
context
.
Background
(),
md
)
c
,
err
=
client
.
FindAllTags
(
ctx
,
rpcRequest
)
require
.
NoError
(
t
,
err
)
```
### Gitlab-Rails
1.
Add feature flag to
`lib/gitlab/gitaly_client.rb`
(in gitlab-rails):
```
ruby
SERVER_FEATURE_FLAGS
=
%w[go-find-all-tags]
.
freeze
```
1.
Test in rails console by setting feature flag:
```
ruby
Feature
.
enable
(
'gitaly_go-find-all-tags'
)
```
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