@@ -13,7 +13,7 @@ import (
13
13
"github.com/prometheus/common/model"
14
14
"google.golang.org/grpc"
15
15
16
- deletion_grpc "github.com/grafana/loki/v3/pkg/compactor/client/grpc"
16
+ compactor_grpc "github.com/grafana/loki/v3/pkg/compactor/client/grpc"
17
17
"github.com/grafana/loki/v3/pkg/compactor/deletion"
18
18
)
19
19
@@ -29,25 +29,26 @@ func (cfg *GRPCConfig) RegisterFlags(f *flag.FlagSet) {
29
29
type compactorGRPCClient struct {
30
30
cfg GRPCConfig
31
31
32
- GRPCClientRequestDuration * prometheus.HistogramVec
32
+ grpcClientRequestDuration * prometheus.HistogramVec
33
33
conn * grpc.ClientConn
34
- grpcClient deletion_grpc.CompactorClient
34
+ grpcClient compactor_grpc.CompactorClient
35
+ jobQueueClient compactor_grpc.JobQueueClient
35
36
}
36
37
37
38
// NewGRPCClient supports only methods which are used for internal communication of Loki like
38
- // loading delete requests and cache gen numbers for query time filtering.
39
- func NewGRPCClient (addr string , cfg GRPCConfig , r prometheus.Registerer ) (deletion. CompactorClient , error ) {
39
+ // loading delete requests, cache gen numbers for query time filtering and interacting with job queue for horizontal scaling of compactor .
40
+ func NewGRPCClient (addr string , cfg GRPCConfig , r prometheus.Registerer ) (CompactorClient , error ) {
40
41
client := & compactorGRPCClient {
41
42
cfg : cfg ,
42
- GRPCClientRequestDuration : promauto .With (r ).NewHistogramVec (prometheus.HistogramOpts {
43
+ grpcClientRequestDuration : promauto .With (r ).NewHistogramVec (prometheus.HistogramOpts {
43
44
Namespace : "loki_compactor" ,
44
45
Name : "grpc_request_duration_seconds" ,
45
46
Help : "Time (in seconds) spent serving requests when using compactor GRPC client" ,
46
47
Buckets : instrument .DefBuckets ,
47
48
}, []string {"operation" , "status_code" }),
48
49
}
49
50
50
- unaryInterceptors , streamInterceptors := grpcclient .Instrument (client .GRPCClientRequestDuration )
51
+ unaryInterceptors , streamInterceptors := grpcclient .Instrument (client .grpcClientRequestDuration )
51
52
dialOpts , err := cfg .GRPCClientConfig .DialOption (unaryInterceptors , streamInterceptors , middleware .NoOpInvalidClusterValidationReporter )
52
53
if err != nil {
53
54
return nil , err
@@ -59,7 +60,8 @@ func NewGRPCClient(addr string, cfg GRPCConfig, r prometheus.Registerer) (deleti
59
60
return nil , err
60
61
}
61
62
62
- client .grpcClient = deletion_grpc .NewCompactorClient (client .conn )
63
+ client .grpcClient = compactor_grpc .NewCompactorClient (client .conn )
64
+ client .jobQueueClient = compactor_grpc .NewJobQueueClient (client .conn )
63
65
return client , nil
64
66
}
65
67
@@ -69,7 +71,7 @@ func (s *compactorGRPCClient) Stop() {
69
71
70
72
func (s * compactorGRPCClient ) GetAllDeleteRequestsForUser (ctx context.Context , userID string ) ([]deletion.DeleteRequest , error ) {
71
73
ctx = user .InjectOrgID (ctx , userID )
72
- grpcResp , err := s .grpcClient .GetDeleteRequests (ctx , & deletion_grpc .GetDeleteRequestsRequest {ForQuerytimeFiltering : true })
74
+ grpcResp , err := s .grpcClient .GetDeleteRequests (ctx , & compactor_grpc .GetDeleteRequestsRequest {ForQuerytimeFiltering : true })
73
75
if err != nil {
74
76
return nil , err
75
77
}
@@ -91,14 +93,18 @@ func (s *compactorGRPCClient) GetAllDeleteRequestsForUser(ctx context.Context, u
91
93
92
94
func (s * compactorGRPCClient ) GetCacheGenerationNumber (ctx context.Context , userID string ) (string , error ) {
93
95
ctx = user .InjectOrgID (ctx , userID )
94
- grpcResp , err := s .grpcClient .GetCacheGenNumbers (ctx , & deletion_grpc .GetCacheGenNumbersRequest {})
96
+ grpcResp , err := s .grpcClient .GetCacheGenNumbers (ctx , & compactor_grpc .GetCacheGenNumbersRequest {})
95
97
if err != nil {
96
98
return "" , err
97
99
}
98
100
99
101
return grpcResp .ResultsCacheGen , nil
100
102
}
101
103
104
+ func (s * compactorGRPCClient ) JobQueueClient () compactor_grpc.JobQueueClient {
105
+ return compactor_grpc .NewJobQueueClient (s .conn )
106
+ }
107
+
102
108
func (s * compactorGRPCClient ) Name () string {
103
109
return "grpc_client"
104
110
}
0 commit comments