github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/callback.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package dbs 15 16 import ( 17 "context" 18 19 "github.com/whtcorpsinc/BerolinaSQL/perceptron" 20 "github.com/whtcorpsinc/milevadb/schemareplicant" 21 "github.com/whtcorpsinc/milevadb/stochastikctx" 22 ) 23 24 // Interceptor is used for DBS. 25 type Interceptor interface { 26 // OnGetSchemaReplicant is an intercept which is called in the function dbs.GetSchemaReplicant(). It is used in the tests. 27 OnGetSchemaReplicant(ctx stochastikctx.Context, is schemareplicant.SchemaReplicant) schemareplicant.SchemaReplicant 28 } 29 30 // BaseInterceptor implements Interceptor. 31 type BaseInterceptor struct{} 32 33 // OnGetSchemaReplicant implements Interceptor.OnGetSchemaReplicant interface. 34 func (bi *BaseInterceptor) OnGetSchemaReplicant(ctx stochastikctx.Context, is schemareplicant.SchemaReplicant) schemareplicant.SchemaReplicant { 35 return is 36 } 37 38 // Callback is used for DBS. 39 type Callback interface { 40 // OnChanged is called after schemaReplicant is changed. 41 OnChanged(err error) error 42 // OnJobRunBefore is called before running job. 43 OnJobRunBefore(job *perceptron.Job) 44 // OnJobUFIDelated is called after the running job is uFIDelated. 45 OnJobUFIDelated(job *perceptron.Job) 46 // OnWatched is called after watching tenant is completed. 47 OnWatched(ctx context.Context) 48 } 49 50 // BaseCallback implements Callback.OnChanged interface. 51 type BaseCallback struct { 52 } 53 54 // OnChanged implements Callback interface. 55 func (c *BaseCallback) OnChanged(err error) error { 56 return err 57 } 58 59 // OnJobRunBefore implements Callback.OnJobRunBefore interface. 60 func (c *BaseCallback) OnJobRunBefore(job *perceptron.Job) { 61 // Nothing to do. 62 } 63 64 // OnJobUFIDelated implements Callback.OnJobUFIDelated interface. 65 func (c *BaseCallback) OnJobUFIDelated(job *perceptron.Job) { 66 // Nothing to do. 67 } 68 69 // OnWatched implements Callback.OnWatched interface. 70 func (c *BaseCallback) OnWatched(ctx context.Context) { 71 // Nothing to do. 72 }