-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Use an abstract lock layer to allow distributed lock between multiple Gitea instances #26486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d15388c
45e783e
a0a74d7
7d568f7
974f6bd
8a62284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1395,6 +1395,11 @@ However, later updates removed those options, and now the only options are `gith | |
However, if you want to use actions from other git server, you can use a complete URL in `uses` field, it's supported by Gitea (but not GitHub). | ||
Like `uses: https://gitea.com/actions/checkout@v3` or `uses: http://your-git-server/actions/checkout@v3`. | ||
|
||
## Sync (`sync`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a small description of what this section does would be useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we just call it |
||
|
||
- `LOCK_SERVICE_TYPE`: **memory**: Lock service type, could be `memory` or `redis` | ||
- `LOCK_SERVICE_CONN_STR`: **\<empty\>**: Ignored when `LOCK_SERVICE_TYPE` is `memory` type, for `redis`, it likes `redis://127.0.0.1:6379/0` | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Other (`other`) | ||
|
||
- `SHOW_FOOTER_VERSION`: **true**: Show Gitea and Go version information in the footer. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package setting | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/log" | ||
"code.gitea.io/gitea/modules/nosql" | ||
) | ||
|
||
// Sync represents configuration of sync | ||
var Sync = struct { | ||
LockServiceType string | ||
LockServiceConnStr string | ||
}{ | ||
LockServiceType: "memory", | ||
} | ||
|
||
func loadSyncFrom(rootCfg ConfigProvider) { | ||
sec := rootCfg.Section("sync") | ||
Sync.LockServiceType = sec.Key("LOCK_SERVICE_TYPE").MustString("memory") | ||
switch Sync.LockServiceType { | ||
case "memory": | ||
case "redis": | ||
connStr := sec.Key("LOCK_SERVICE_CONN_STR").String() | ||
if connStr == "" { | ||
log.Fatal("LOCK_SERVICE_CONN_STR is empty for redis") | ||
} | ||
u := nosql.ToRedisURI(connStr) | ||
if u == nil { | ||
log.Fatal("LOCK_SERVICE_CONN_STR %s is not right for redis", connStr) | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
Sync.LockServiceConnStr = connStr | ||
default: | ||
log.Fatal("Unknown sync lock service type: %s", Sync.LockServiceType) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package setting | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLoadSyncConfig(t *testing.T) { | ||
t.Run("DefaultSyncConfig", func(t *testing.T) { | ||
iniStr := `` | ||
cfg, err := NewConfigProviderFromData(iniStr) | ||
assert.NoError(t, err) | ||
|
||
loadSyncFrom(cfg) | ||
assert.EqualValues(t, "memory", Sync.LockServiceType) | ||
}) | ||
|
||
t.Run("RedisSyncConfig", func(t *testing.T) { | ||
iniStr := ` | ||
[sync] | ||
LOCK_SERVICE_TYPE = redis | ||
LOCK_SERVICE_CONN_STR = addrs=127.0.0.1:6379 db=0 | ||
` | ||
cfg, err := NewConfigProviderFromData(iniStr) | ||
assert.NoError(t, err) | ||
|
||
loadSyncFrom(cfg) | ||
assert.EqualValues(t, "redis", Sync.LockServiceType) | ||
assert.EqualValues(t, "addrs=127.0.0.1:6379 db=0", Sync.LockServiceConnStr) | ||
}) | ||
} |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.