Skip to content

Commit 8015da1

Browse files
fix
1 parent d869032 commit 8015da1

31 files changed

Lines changed: 401 additions & 521 deletions

cmd/seq-ui/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ func initApp(ctx context.Context, cfg config.Config) *api.Registrar {
163163
userProfileV1 = userprofile_v1.New(svc, p)
164164
dashboardsV1 = dashboards_v1.New(svc, p)
165165

166-
asyncSearchesService = asyncsearches.New(ctx, repo, defaultClient, cfg.Handlers.AsyncSearch.AdminUsers)
166+
asyncSearchesService = asyncsearches.New(ctx, repo, defaultClient, cfg.Handlers.AsyncSearch)
167167
}
168168

169-
seqApiV1 := seqapi_v1.New(*cfg.Handlers, seqDBClients, inmemWithRedisCache, redisCache, asyncSearchesService, p)
169+
seqApiV1 := seqapi_v1.New(cfg.Handlers.SeqAPI, seqDBClients, inmemWithRedisCache, redisCache, asyncSearchesService, p)
170170

171171
logger.Info("initializing clickhouse")
172172
ch, err := initClickHouse(ctx, cfg.Server.CH)

docs/en/02-configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,19 +809,19 @@ Config for `/massexport` API handlers.
809809

810810
### Async Search
811811

812-
Configuration for async request.
812+
Configuration for async search request.
813813

814814
**`async_search`** *`AsyncSearch`* *`optional`*
815815

816-
Поля `AsyncSearch`:
816+
Fields `AsyncSearch`:
817817

818818
+ **`admin_users`** *`[]string`* *`optional`*
819819

820820
List of users allowed to cancel or delete async requests created by other users.
821821

822822
+ **`query_length_limit`** *`int`* *`default=1000`*
823823

824-
Maximum length of `request.query` in async searches list responses.
824+
Maximum length of `request.query` in async searches list responses. Requests exceeding the limit will be truncated to it
825825

826826
## Tracing
827827

docs/ru/02-configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,17 +811,17 @@ handlers:
811811

812812
**`async_search`** *`AsyncSearch`* *`optional`*
813813

814-
Настройка функциональности отложенных запросов.
814+
Настройка функциональности отложенных поисковых запросов.
815815

816816
Поля `AsyncSearch`:
817817

818818
+ **`admin_users`** *`[]string`* *`optional`*
819819

820820
Список пользователей, которые могут отменять или удалять отложенные поиски других пользователей.
821821

822-
+ **`query_length_limit`** *`int`* *`default=1000`*
822+
+ **`list_query_length_limit`** *`int`* *`default=1000`*
823823

824-
Максимальная длина `request.query` в ответе списка отложенных запросов.
824+
Максимальная длина `request.query` в ответе списка отложенных запросов. Запросы, превышающие лимит, будут обрезаны до этого значения.
825825

826826
## Tracing
827827

internal/api/seqapi/v1/grpc/aggregation_test.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestGetAggregation(t *testing.T) {
3030
apiErr bool
3131
clientErr error
3232

33-
cfg config.Handlers
33+
cfg config.SeqAPI
3434
}{
3535
{
3636
name: "ok_single_agg",
@@ -47,11 +47,9 @@ func TestGetAggregation(t *testing.T) {
4747
Code: seqapi.ErrorCode_ERROR_CODE_NO,
4848
},
4949
},
50-
cfg: config.Handlers{
51-
SeqAPI: config.SeqAPI{
52-
SeqAPIOptions: &config.SeqAPIOptions{
53-
MaxAggregationsPerRequest: 4,
54-
},
50+
cfg: config.SeqAPI{
51+
SeqAPIOptions: &config.SeqAPIOptions{
52+
MaxAggregationsPerRequest: 4,
5553
},
5654
},
5755
},
@@ -73,11 +71,9 @@ func TestGetAggregation(t *testing.T) {
7371
Code: seqapi.ErrorCode_ERROR_CODE_NO,
7472
},
7573
},
76-
cfg: config.Handlers{
77-
SeqAPI: config.SeqAPI{
78-
SeqAPIOptions: &config.SeqAPIOptions{
79-
MaxAggregationsPerRequest: 3,
80-
},
74+
cfg: config.SeqAPI{
75+
SeqAPIOptions: &config.SeqAPIOptions{
76+
MaxAggregationsPerRequest: 3,
8177
},
8278
},
8379
},
@@ -90,11 +86,9 @@ func TestGetAggregation(t *testing.T) {
9086
{Field: "test3"},
9187
},
9288
},
93-
cfg: config.Handlers{
94-
SeqAPI: config.SeqAPI{
95-
SeqAPIOptions: &config.SeqAPIOptions{
96-
MaxAggregationsPerRequest: 2,
97-
},
89+
cfg: config.SeqAPI{
90+
SeqAPIOptions: &config.SeqAPIOptions{
91+
MaxAggregationsPerRequest: 2,
9892
},
9993
},
10094
apiErr: true,
@@ -107,11 +101,9 @@ func TestGetAggregation(t *testing.T) {
107101
To: timestamppb.New(to),
108102
AggField: "test2",
109103
},
110-
cfg: config.Handlers{
111-
SeqAPI: config.SeqAPI{
112-
SeqAPIOptions: &config.SeqAPIOptions{
113-
MaxAggregationsPerRequest: 1,
114-
},
104+
cfg: config.SeqAPI{
105+
SeqAPIOptions: &config.SeqAPIOptions{
106+
MaxAggregationsPerRequest: 1,
115107
},
116108
},
117109
clientErr: errors.New("client error"),

internal/api/seqapi/v1/grpc/api.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type apiParams struct {
3232
type API struct {
3333
seqapi.UnimplementedSeqAPIServiceServer
3434

35-
config config.Handlers
35+
config config.SeqAPI
3636
params apiParams
3737
paramsByEnv map[string]apiParams
3838
inmemWithRedisCache cache.Cache
@@ -44,31 +44,31 @@ type API struct {
4444
}
4545

4646
func New(
47-
cfg config.Handlers,
47+
cfg config.SeqAPI,
4848
seqDBСlients map[string]seqdb.Client,
4949
inmemWithRedisCache cache.Cache,
5050
redisCache cache.Cache,
5151
asyncSearches *asyncsearches.Service,
5252
p *profiles.Profiles,
5353
) *API {
5454
var globalfCache *fieldsCache
55-
if cfg.SeqAPI.FieldsCacheTTL > 0 {
56-
globalfCache = newFieldsCache(cfg.SeqAPI.FieldsCacheTTL)
55+
if cfg.FieldsCacheTTL > 0 {
56+
globalfCache = newFieldsCache(cfg.FieldsCacheTTL)
5757
}
5858

59-
globalMasker, err := mask.New(cfg.SeqAPI.Masking)
59+
globalMasker, err := mask.New(cfg.Masking)
6060
if err != nil {
6161
logger.Fatal("failed to init masking", zap.Error(err))
6262
}
6363

64-
globalPinnedFields := parsePinnedFields(cfg.SeqAPI.PinnedFields)
64+
globalPinnedFields := parsePinnedFields(cfg.PinnedFields)
6565

6666
var params apiParams
6767
var paramsByEnv map[string]apiParams
6868

69-
if len(cfg.SeqAPI.Envs) > 0 {
69+
if len(cfg.Envs) > 0 {
7070
paramsByEnv = make(map[string]apiParams)
71-
for envName, envConfig := range cfg.SeqAPI.Envs {
71+
for envName, envConfig := range cfg.Envs {
7272
client := seqDBСlients[envConfig.SeqDB]
7373
options := envConfig.Options
7474

@@ -101,7 +101,7 @@ func New(
101101

102102
params = apiParams{
103103
client: client,
104-
options: cfg.SeqAPI.SeqAPIOptions,
104+
options: cfg.SeqAPIOptions,
105105
fieldsCache: globalfCache,
106106
masker: globalMasker,
107107
pinnedFields: globalPinnedFields,
@@ -117,7 +117,7 @@ func New(
117117
nowFn: time.Now,
118118
asyncSearches: asyncSearches,
119119
profiles: p,
120-
envsResponse: parseEnvs(cfg.SeqAPI),
120+
envsResponse: parseEnvs(cfg),
121121
}
122122
}
123123

@@ -191,12 +191,12 @@ func (a *API) GetEnvFromContext(ctx context.Context) string {
191191
}
192192

193193
func (a *API) GetParams(env string) (apiParams, error) {
194-
if len(a.config.SeqAPI.Envs) == 0 {
194+
if len(a.config.Envs) == 0 {
195195
return a.params, nil
196196
}
197197

198198
if env == "" {
199-
env = a.config.SeqAPI.DefaultEnv
199+
env = a.config.DefaultEnv
200200
}
201201

202202
params, exists := a.paramsByEnv[env]

internal/api/seqapi/v1/grpc/cluster_status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestStatus(t *testing.T) {
6464
seqDbMock.EXPECT().Status(gomock.Any(), nil).
6565
Return(proto.Clone(tt.resp), tt.clientErr).Times(1)
6666

67-
cfg := config.Handlers{}
67+
cfg := config.SeqAPI{}
6868

6969
seqData := test.APITestData{
7070
Cfg: cfg,

internal/api/seqapi/v1/grpc/events_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ func TestGetEvent(t *testing.T) {
102102
t.Parallel()
103103

104104
seqData := test.APITestData{
105-
Cfg: config.Handlers{
106-
SeqAPI: config.SeqAPI{
107-
SeqAPIOptions: &config.SeqAPIOptions{
108-
EventsCacheTTL: cacheTTL,
109-
},
105+
Cfg: config.SeqAPI{
106+
SeqAPIOptions: &config.SeqAPIOptions{
107+
EventsCacheTTL: cacheTTL,
110108
},
111109
},
112110
}
@@ -366,12 +364,10 @@ func TestGetEventWithMasking(t *testing.T) {
366364
curEID := curEData.id
367365

368366
seqData := test.APITestData{
369-
Cfg: config.Handlers{
370-
SeqAPI: config.SeqAPI{
371-
SeqAPIOptions: &config.SeqAPIOptions{
372-
EventsCacheTTL: cacheTTL,
373-
Masking: tt.maskingCfg,
374-
},
367+
Cfg: config.SeqAPI{
368+
SeqAPIOptions: &config.SeqAPIOptions{
369+
EventsCacheTTL: cacheTTL,
370+
Masking: tt.maskingCfg,
375371
},
376372
},
377373
}

internal/api/seqapi/v1/grpc/fields_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ func TestGetFieldsCached(t *testing.T) {
106106
const ttl = 20 * time.Millisecond
107107

108108
seqData := test.APITestData{
109-
Cfg: config.Handlers{
110-
SeqAPI: config.SeqAPI{
111-
SeqAPIOptions: &config.SeqAPIOptions{
112-
FieldsCacheTTL: ttl,
113-
},
109+
Cfg: config.SeqAPI{
110+
SeqAPIOptions: &config.SeqAPIOptions{
111+
FieldsCacheTTL: ttl,
114112
},
115113
},
116114
Mocks: test.Mocks{
@@ -156,11 +154,9 @@ func TestGetPinnedFields(t *testing.T) {
156154
t.Parallel()
157155

158156
seqData := test.APITestData{
159-
Cfg: config.Handlers{
160-
SeqAPI: config.SeqAPI{
161-
SeqAPIOptions: &config.SeqAPIOptions{
162-
PinnedFields: tt.fields,
163-
},
157+
Cfg: config.SeqAPI{
158+
SeqAPIOptions: &config.SeqAPIOptions{
159+
PinnedFields: tt.fields,
164160
},
165161
},
166162
}

0 commit comments

Comments
 (0)