Boards data retention (#19262)
* add Boards to DataRetention, add hook for data retention * remove replaces * update hook to remove parameter * add boards data retention to telemetry * fix unit test * update test, update hooks * update RunDataRetention server version * put behind a feature flag Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
294bd44971
Коммит
956e21cfa2
@@ -669,6 +669,43 @@ func (s *hooksRPCServer) WebSocketMessageHasBeenPosted(args *Z_WebSocketMessageH
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["RunDataRetention"] = RunDataRetentionID
|
||||
}
|
||||
|
||||
type Z_RunDataRetentionArgs struct {
|
||||
A int64
|
||||
B int64
|
||||
}
|
||||
|
||||
type Z_RunDataRetentionReturns struct {
|
||||
A int64
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) RunDataRetention(nowTime, batchSize int64) (int64, error) {
|
||||
_args := &Z_RunDataRetentionArgs{nowTime, batchSize}
|
||||
_returns := &Z_RunDataRetentionReturns{}
|
||||
if g.implemented[RunDataRetentionID] {
|
||||
if err := g.client.Call("Plugin.RunDataRetention", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call RunDataRetention to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) RunDataRetention(args *Z_RunDataRetentionArgs, returns *Z_RunDataRetentionReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
RunDataRetention(nowTime, batchSize int64) (int64, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.RunDataRetention(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("Hook RunDataRetention called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_RegisterCommandArgs struct {
|
||||
A *model.Command
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
OnWebSocketConnectID = 21
|
||||
OnWebSocketDisconnectID = 22
|
||||
WebSocketMessageHasBeenPostedID = 23
|
||||
RunDataRetentionID = 24
|
||||
TotalHooksID = iota
|
||||
)
|
||||
|
||||
@@ -243,4 +244,9 @@ type Hooks interface {
|
||||
//
|
||||
// Minimum server version: 6.0
|
||||
WebSocketMessageHasBeenPosted(webConnID, userID string, req *model.WebSocketRequest)
|
||||
|
||||
// RunDataRetention is invoked during a DataRetentionJob
|
||||
//
|
||||
// Minimum server version: 6.4
|
||||
RunDataRetention(nowTime, batchSize int64) (int64, error)
|
||||
}
|
||||
|
||||
@@ -186,3 +186,10 @@ func (hooks *hooksTimerLayer) WebSocketMessageHasBeenPosted(webConnID, userID st
|
||||
hooks.hooksImpl.WebSocketMessageHasBeenPosted(webConnID, userID, req)
|
||||
hooks.recordTime(startTime, "WebSocketMessageHasBeenPosted", true)
|
||||
}
|
||||
|
||||
func (hooks *hooksTimerLayer) RunDataRetention(nowTime, batchSize int64) (int64, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := hooks.hooksImpl.RunDataRetention(nowTime, batchSize)
|
||||
hooks.recordTime(startTime, "RunDataRetention", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
@@ -219,6 +219,27 @@ func (_m *Hooks) ReactionHasBeenRemoved(c *plugin.Context, reaction *model.React
|
||||
_m.Called(c, reaction)
|
||||
}
|
||||
|
||||
// RunDataRetention provides a mock function with given fields: nowTime, batchSize
|
||||
func (_m *Hooks) RunDataRetention(nowTime int64, batchSize int64) (int64, error) {
|
||||
ret := _m.Called(nowTime, batchSize)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(int64, int64) int64); ok {
|
||||
r0 = rf(nowTime, batchSize)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64, int64) error); ok {
|
||||
r1 = rf(nowTime, batchSize)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ServeHTTP provides a mock function with given fields: c, w, r
|
||||
func (_m *Hooks) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
|
||||
_m.Called(c, w, r)
|
||||
|
||||
Ссылка в новой задаче
Block a user