Skip to content

Commit cb0ecdd

Browse files
committed
feat: bill check
1 parent 412aac3 commit cb0ecdd

File tree

6 files changed

+65
-0
lines changed

6 files changed

+65
-0
lines changed

server/controller/config/common/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ type Warrant struct {
2727
Timeout int `default:"30" yaml:"timeout"`
2828
}
2929

30+
type Manager struct {
31+
Enabled bool `default:"false" yaml:"enabled"`
32+
Host string `default:"manager" yaml:"host"`
33+
Port int `default:"20403" yaml:"port"`
34+
Timeout int `default:"30" yaml:"timeout"`
35+
}
36+
3037
type FPermit struct {
3138
Enabled bool `default:"false" yaml:"enabled"`
3239
Host string `default:"fpermit" yaml:"host"`

server/controller/controller/master.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/deepflowio/deepflow/server/controller/http/service"
3030
resoureservice "github.com/deepflowio/deepflow/server/controller/http/service/resource"
3131
"github.com/deepflowio/deepflow/server/controller/monitor"
32+
"github.com/deepflowio/deepflow/server/controller/monitor/bill"
3233
"github.com/deepflowio/deepflow/server/controller/monitor/license"
3334
"github.com/deepflowio/deepflow/server/controller/monitor/vtap"
3435
"github.com/deepflowio/deepflow/server/controller/prometheus"
@@ -96,6 +97,7 @@ func checkAndStartMasterFunctions(
9697
vtapCheck := vtap.NewVTapCheck(cfg.MonitorCfg, ctx)
9798
vtapRebalanceCheck := vtap.NewRebalanceCheck(cfg.MonitorCfg, ctx)
9899
vtapLicenseAllocation := license.NewVTapLicenseAllocation(cfg.MonitorCfg, ctx)
100+
billCheck := bill.NewBillCheck(cfg.BillingMethod, cfg.MonitorCfg, ctx)
99101
recorderResource := recorder.GetResource()
100102
domainChecker := resoureservice.NewDomainCheck(ctx)
101103
prometheus := prometheus.GetSingleton()
@@ -151,6 +153,9 @@ func checkAndStartMasterFunctions(
151153
vtapLicenseAllocation.Start(sCtx)
152154
}
153155

156+
// bill check
157+
billCheck.Start(sCtx)
158+
154159
// 资源数据清理
155160
recorderResource.Cleaners.Start(sCtx)
156161

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2024 Yunshan Networks
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package bill
18+
19+
import (
20+
"context"
21+
22+
"github.com/deepflowio/deepflow/server/controller/monitor/config"
23+
)
24+
25+
type BillCheck struct {
26+
vCtx context.Context
27+
vCancel context.CancelFunc
28+
config config.MonitorConfig
29+
}
30+
31+
func NewBillCheck(method string, cfg config.MonitorConfig, ctx context.Context) *BillCheck {
32+
vCtx, vCancel := context.WithCancel(ctx)
33+
return &BillCheck{
34+
vCtx: vCtx,
35+
vCancel: vCancel,
36+
config: cfg,
37+
}
38+
}
39+
40+
func (b *BillCheck) Start(sCtx context.Context) {}
41+
42+
func (b *BillCheck) Stop() {
43+
if b.vCancel != nil {
44+
b.vCancel()
45+
}
46+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/deepflowio/deepflow/server/controller/monitor/bill
2+
3+
go 1.24

server/controller/monitor/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ type MonitorConfig struct {
2525
HealthCheckPort int `default:"30417" yaml:"health_check_port"`
2626
HealthCheckHandleChannelLen int `default:"1000" yaml:"health_check_handle_channel_len"`
2727
LicenseCheckInterval int `default:"60" yaml:"license_check_interval"`
28+
BillCheckInterval int `default:"3600" yaml:"bill_check_interval"`
2829
VTapCheckInterval int `default:"60" yaml:"vtap_check_interval"`
2930
ExceptionTimeFrame int `default:"3600" yaml:"exception_time_frame"`
3031
AutoRebalanceVTap bool `default:"true" yaml:"auto_rebalance_vtap"`
3132
RebalanceCheckInterval int `default:"300" yaml:"rebalance_check_interval"` // unit: second
3233
VTapAutoDelete VTapAutoDelete `yaml:"vtap_auto_delete"`
3334
Warrant configs.Warrant `yaml:"warrant"`
35+
Manager configs.Manager `yaml:"manager"`
3436
IngesterLoadBalancingConfig IngesterLoadBalancingStrategy `yaml:"ingester-load-balancing-strategy"`
3537
SyncDefaultORGDataInterval int `default:"10" yaml:"sync_default_org_data_interval"`
3638
}

server/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ replace (
1616
github.com/deepflowio/deepflow/server/controller/http/appender => ./controller/http/appender
1717
github.com/deepflowio/deepflow/server/controller/http/service/agentlicense => ./controller/http/service/agentlicense
1818
github.com/deepflowio/deepflow/server/controller/http/service/configuration => ./controller/http/service/configuration
19+
github.com/deepflowio/deepflow/server/controller/monitor/bill => ./controller/monitor/bill
1920
github.com/deepflowio/deepflow/server/controller/monitor/license => ./controller/monitor/license
2021
github.com/deepflowio/deepflow/server/controller/monitor/vtap/version => ./controller/monitor/vtap/version
2122
github.com/deepflowio/deepflow/server/controller/native_field => ./controller/native_field
@@ -67,6 +68,7 @@ require (
6768
github.com/deepflowio/deepflow/server/controller/genesis/store/sync/redis v0.0.0-00010101000000-000000000000
6869
github.com/deepflowio/deepflow/server/controller/http/appender v0.0.0-00010101000000-000000000000
6970
github.com/deepflowio/deepflow/server/controller/http/service/agentlicense v0.0.0-00010101000000-000000000000
71+
github.com/deepflowio/deepflow/server/controller/monitor/bill v0.0.0-00010101000000-000000000000
7072
github.com/deepflowio/deepflow/server/controller/monitor/license v0.0.0-00010101000000-000000000000
7173
github.com/deepflowio/deepflow/server/controller/monitor/vtap/version v0.0.0-00010101000000-000000000000
7274
github.com/deepflowio/deepflow/server/controller/native_field v0.0.0-00010101000000-000000000000

0 commit comments

Comments
 (0)