增加对访问日志自动分表配置

This commit is contained in:
GoEdgeLab
2022-03-09 10:01:52 +08:00
parent 6b5dd1d82a
commit 93e80230dd
2 changed files with 34 additions and 9 deletions

View File

@@ -27,9 +27,11 @@ func (this *SettingsAction) RunGet(params struct{}) {
} }
var config = &serverconfigs.AccessLogQueueConfig{ var config = &serverconfigs.AccessLogQueueConfig{
MaxLength: 0, MaxLength: 0,
CountPerSecond: 0, CountPerSecond: 0,
Percent: 100, Percent: 100,
EnableAutoPartial: true,
RowsPerTable: 500_000,
} }
if len(settingsResp.ValueJSON) > 0 { if len(settingsResp.ValueJSON) > 0 {
err = json.Unmarshal(settingsResp.ValueJSON, config) err = json.Unmarshal(settingsResp.ValueJSON, config)
@@ -59,9 +61,11 @@ func (this *SettingsAction) RunGet(params struct{}) {
} }
func (this *SettingsAction) RunPost(params struct { func (this *SettingsAction) RunPost(params struct {
Percent int Percent int
CountPerSecond int CountPerSecond int
MaxLength int MaxLength int
EnableAutoPartial bool
RowsPerTable int64
Must *actions.Must Must *actions.Must
CSRF *actionutils.CSRF CSRF *actionutils.CSRF
@@ -72,9 +76,11 @@ func (this *SettingsAction) RunPost(params struct {
Lte(100, "请输入小于100的整数") Lte(100, "请输入小于100的整数")
var config = &serverconfigs.AccessLogQueueConfig{ var config = &serverconfigs.AccessLogQueueConfig{
MaxLength: params.MaxLength, MaxLength: params.MaxLength,
CountPerSecond: params.CountPerSecond, CountPerSecond: params.CountPerSecond,
Percent: params.Percent, Percent: params.Percent,
EnableAutoPartial: params.EnableAutoPartial,
RowsPerTable: params.RowsPerTable,
} }
configJSON, err := json.Marshal(config) configJSON, err := json.Marshal(config)
if err != nil { if err != nil {

View File

@@ -41,5 +41,24 @@
</td> </td>
</tr> </tr>
</table> </table>
<h3>自动分表设置</h3>
<table class="ui table definition selectable">
<tr>
<td class="title">启用自动分表</td>
<td>
<checkbox name="enableAutoPartial" v-model="config.enableAutoPartial"></checkbox>
<p class="comment">启用后,可以将单天访问日志自动存储到多个数据表中,以提升查询速度。</p>
</td>
</tr>
<tr v-show="config.enableAutoPartial">
<td>单表最多行数</td>
<td>
<input type="text" style="width: 8em" name="rowsPerTable" v-model="config.rowsPerTable" maxlength="16"/>
<p class="comment">单个数据表最多能存储的最多行数。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>