diff --git a/quesma/go.mod b/quesma/go.mod index cea128ff4..706e6a0ce 100644 --- a/quesma/go.mod +++ b/quesma/go.mod @@ -31,7 +31,6 @@ require ( github.com/stretchr/testify v1.10.0 github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a github.com/tidwall/sjson v1.2.5 - github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f golang.org/x/oauth2 v0.24.0 quesma_v2 v0.0.0-00010101000000-000000000000 @@ -57,6 +56,7 @@ require ( github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect + github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect golang.org/x/crypto v0.28.0 // indirect golang.org/x/text v0.19.0 // indirect ) diff --git a/quesma/ingest/common_table_test.go b/quesma/ingest/common_table_test.go index 158dc8071..4477ab939 100644 --- a/quesma/ingest/common_table_test.go +++ b/quesma/ingest/common_table_test.go @@ -9,13 +9,13 @@ import ( "github.com/stretchr/testify/assert" "quesma/clickhouse" "quesma/common_table" - "quesma/frontend_connectors" "quesma/jsonprocessor" "quesma/persistence" "quesma/quesma/config" "quesma/quesma/types" "quesma/schema" "quesma/table_resolver" + "quesma_v2/core/mux" "testing" ) @@ -192,9 +192,9 @@ func TestIngestToCommonTable(t *testing.T) { resolver := table_resolver.NewEmptyTableResolver() - decision := &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{ - &frontend_connectors.ConnectorDecisionClickhouse{ + decision := &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{ + &mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{indexName}, IsCommonTable: true, diff --git a/quesma/ingest/ingest_validator_test.go b/quesma/ingest/ingest_validator_test.go index 8db41c50c..4be4bdaab 100644 --- a/quesma/ingest/ingest_validator_test.go +++ b/quesma/ingest/ingest_validator_test.go @@ -9,11 +9,11 @@ import ( "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/assert" "quesma/clickhouse" - "quesma/frontend_connectors" "quesma/quesma/config" "quesma/quesma/types" "quesma/table_resolver" "quesma/util" + "quesma_v2/core/mux" "strings" "testing" ) @@ -172,8 +172,8 @@ func TestIngestValidation(t *testing.T) { ip.tableDiscovery = clickhouse.NewTableDiscoveryWith(&config.QuesmaConfiguration{}, nil, *tableMap) resolver := table_resolver.NewEmptyTableResolver() - decision := &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + decision := &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "test_table", }}} resolver.Decisions["test_table"] = decision diff --git a/quesma/ingest/insert_test.go b/quesma/ingest/insert_test.go index 383cef8b0..61c07e1e9 100644 --- a/quesma/ingest/insert_test.go +++ b/quesma/ingest/insert_test.go @@ -8,7 +8,6 @@ import ( "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/assert" "quesma/clickhouse" - "quesma/frontend_connectors" "quesma/jsonprocessor" "quesma/persistence" "quesma/quesma/config" @@ -16,6 +15,7 @@ import ( "quesma/schema" "quesma/table_resolver" "quesma/util" + "quesma_v2/core/mux" "slices" "strconv" "strings" @@ -240,8 +240,8 @@ func TestProcessInsertQuery(t *testing.T) { db, mock := util.InitSqlMockWithPrettyPrint(t, true) ip.ip.chDb = db resolver := table_resolver.NewEmptyTableResolver() - decision := &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + decision := &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "test_table", }}} resolver.Decisions["test_table"] = decision @@ -425,8 +425,8 @@ func TestCreateTableIfSomeFieldsExistsInSchemaAlready(t *testing.T) { schemaRegistry.Tables[schema.TableName(indexName)] = indexSchema resolver := table_resolver.NewEmptyTableResolver() - decision := &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + decision := &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "test_index", }}} resolver.Decisions["test_index"] = decision diff --git a/quesma/ingest/processor.go b/quesma/ingest/processor.go index 7f4c7b353..3f5cca6fc 100644 --- a/quesma/ingest/processor.go +++ b/quesma/ingest/processor.go @@ -12,7 +12,6 @@ import ( "quesma/comment_metadata" "quesma/common_table" "quesma/end_user_errors" - "quesma/frontend_connectors" "quesma/jsonprocessor" "quesma/logger" "quesma/model" @@ -25,6 +24,7 @@ import ( "quesma/table_resolver" "quesma/telemetry" "quesma/util" + "quesma_v2/core/mux" "slices" "sort" "strings" @@ -696,7 +696,7 @@ func (lm *IngestProcessor) ProcessInsertQuery(ctx context.Context, tableName str jsonData []types.JSON, transformer jsonprocessor.IngestTransformer, tableFormatter TableColumNameFormatter) error { - decision := lm.tableResolver.Resolve(frontend_connectors.IngestPipeline, tableName) + decision := lm.tableResolver.Resolve(mux.IngestPipeline, tableName) if decision.Err != nil { return decision.Err @@ -712,10 +712,10 @@ func (lm *IngestProcessor) ProcessInsertQuery(ctx context.Context, tableName str for _, connectorDecision := range decision.UseConnectors { - var clickhouseDecision *frontend_connectors.ConnectorDecisionClickhouse + var clickhouseDecision *mux.ConnectorDecisionClickhouse var ok bool - if clickhouseDecision, ok = connectorDecision.(*frontend_connectors.ConnectorDecisionClickhouse); !ok { + if clickhouseDecision, ok = connectorDecision.(*mux.ConnectorDecisionClickhouse); !ok { continue } diff --git a/quesma/quesma/dual_write_proxy.go b/quesma/quesma/dual_write_proxy.go index 2530a99d3..6e188fbd8 100644 --- a/quesma/quesma/dual_write_proxy.go +++ b/quesma/quesma/dual_write_proxy.go @@ -15,9 +15,6 @@ import ( "quesma/elasticsearch" "quesma/end_user_errors" "quesma/feature" - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" - "quesma/frontend_connectors/routes" "quesma/ingest" "quesma/logger" "quesma/queryparser" @@ -32,6 +29,8 @@ import ( "quesma/telemetry" "quesma/tracing" "quesma/util" + "quesma_v2/core/mux" + "quesma_v2/core/routes" "strconv" "strings" "sync/atomic" @@ -54,7 +53,6 @@ func newSimultaneousClientsLimiter(handler http.Handler, limit int64) *simultane } func (c *simultaneousClientsLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) { - current := c.counter.Load() // this is hard limit, we should not allow to go over it if current >= c.limit { @@ -369,7 +367,7 @@ func (r *router) reroute(ctx context.Context, w http.ResponseWriter, req *http.R } for _, connector := range decision.UseConnectors { - if _, ok := connector.(*frontend_connectors.ConnectorDecisionElastic); ok { + if _, ok := connector.(*mux.ConnectorDecisionElastic); ok { // this is desired elastic call sendToElastic = true break diff --git a/quesma/quesma/dual_write_proxy_v2.go b/quesma/quesma/dual_write_proxy_v2.go index 45ae50d5d..d7bcd5cb0 100644 --- a/quesma/quesma/dual_write_proxy_v2.go +++ b/quesma/quesma/dual_write_proxy_v2.go @@ -15,9 +15,6 @@ import ( "quesma/elasticsearch" "quesma/end_user_errors" "quesma/feature" - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" - "quesma/frontend_connectors/routes" "quesma/ingest" "quesma/logger" "quesma/queryparser" @@ -32,6 +29,8 @@ import ( "quesma/telemetry" "quesma/tracing" "quesma/util" + "quesma_v2/core/mux" + "quesma_v2/core/routes" "strconv" "strings" "sync/atomic" @@ -276,7 +275,7 @@ func (*routerV2) closedIndexResponse(ctx context.Context, w http.ResponseWriter, } -func (r *routerV2) elasticFallback(decision *frontend_connectors.Decision, +func (r *routerV2) elasticFallback(decision *mux.Decision, ctx context.Context, w http.ResponseWriter, req *http.Request, reqBody []byte, logManager *clickhouse.LogManager) { @@ -307,7 +306,7 @@ func (r *routerV2) elasticFallback(decision *frontend_connectors.Decision, } for _, connector := range decision.UseConnectors { - if _, ok := connector.(*frontend_connectors.ConnectorDecisionElastic); ok { + if _, ok := connector.(*mux.ConnectorDecisionElastic); ok { // this is desired elastic call sendToElastic = true break @@ -360,7 +359,7 @@ func (r *routerV2) reroute(ctx context.Context, w http.ResponseWriter, req *http quesmaRequest.ParsedBody = types.ParseRequestBody(quesmaRequest.Body) var handler mux.Handler - var decision *frontend_connectors.Decision + var decision *mux.Decision searchHandler, searchDecision := searchRouter.Matches(quesmaRequest) if searchDecision != nil { decision = searchDecision diff --git a/quesma/quesma/elastic_http_frontend_connector.go b/quesma/quesma/elastic_http_frontend_connector.go index 322d03d57..2acfca1ca 100644 --- a/quesma/quesma/elastic_http_frontend_connector.go +++ b/quesma/quesma/elastic_http_frontend_connector.go @@ -7,9 +7,9 @@ import ( "net/http" "quesma/clickhouse" "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" "quesma/quesma/recovery" "quesma/telemetry" + "quesma_v2/core/mux" ) type ElasticHttpFrontendConnector struct { diff --git a/quesma/quesma/functionality/bulk/bulk.go b/quesma/quesma/functionality/bulk/bulk.go index e5bf6fc92..2785d7805 100644 --- a/quesma/quesma/functionality/bulk/bulk.go +++ b/quesma/quesma/functionality/bulk/bulk.go @@ -11,7 +11,6 @@ import ( "quesma/clickhouse" "quesma/elasticsearch" "quesma/end_user_errors" - "quesma/frontend_connectors" "quesma/ingest" "quesma/logger" "quesma/queryparser" @@ -21,6 +20,7 @@ import ( "quesma/stats" "quesma/table_resolver" "quesma/telemetry" + "quesma_v2/core/mux" "sort" "strings" "sync" @@ -139,7 +139,7 @@ func splitBulk(ctx context.Context, defaultIndex *string, bulk types.NDJSON, bul } } - decision := tableResolver.Resolve(frontend_connectors.IngestPipeline, index) + decision := tableResolver.Resolve(mux.IngestPipeline, index) if decision.Err != nil { return decision.Err @@ -181,7 +181,7 @@ func splitBulk(ctx context.Context, defaultIndex *string, bulk types.NDJSON, bul switch connector.(type) { - case *frontend_connectors.ConnectorDecisionElastic: + case *mux.ConnectorDecisionElastic: // Bulk entry for Elastic - forward the request as-is opBytes, err := rawOp.Bytes() if err != nil { @@ -199,7 +199,7 @@ func splitBulk(ctx context.Context, defaultIndex *string, bulk types.NDJSON, bul elasticBulkEntries = append(elasticBulkEntries, entryWithResponse) - case *frontend_connectors.ConnectorDecisionClickhouse: + case *mux.ConnectorDecisionClickhouse: // Bulk entry for Clickhouse if operation != "create" && operation != "index" { diff --git a/quesma/quesma/matchers.go b/quesma/quesma/matchers.go index ca5a63532..52c779adb 100644 --- a/quesma/quesma/matchers.go +++ b/quesma/quesma/matchers.go @@ -3,13 +3,12 @@ package quesma import ( - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" "quesma/logger" "quesma/quesma/config" "quesma/quesma/types" "quesma/table_resolver" "quesma/tracing" + "quesma_v2/core/mux" "strings" ) @@ -34,7 +33,7 @@ func matchedAgainstBulkBody(configuration *config.QuesmaConfiguration, tableReso if idx%2 == 0 { name := extractIndexName(s) - decision := tableResolver.Resolve(frontend_connectors.IngestPipeline, name) + decision := tableResolver.Resolve(mux.IngestPipeline, name) if decision.IsClosed { return mux.MatchResult{Matched: true, Decision: decision} @@ -42,7 +41,7 @@ func matchedAgainstBulkBody(configuration *config.QuesmaConfiguration, tableReso // if have any enabled Clickhouse connector, then return true for _, connector := range decision.UseConnectors { - if _, ok := connector.(*frontend_connectors.ConnectorDecisionClickhouse); ok { + if _, ok := connector.(*mux.ConnectorDecisionClickhouse); ok { return mux.MatchResult{Matched: true, Decision: decision} } } @@ -57,7 +56,7 @@ func matchedAgainstBulkBody(configuration *config.QuesmaConfiguration, tableReso // Query path only (looks at QueryTarget) func matchedAgainstPattern(indexRegistry table_resolver.TableResolver) mux.RequestMatcher { - return matchAgainstTableResolver(indexRegistry, frontend_connectors.QueryPipeline) + return matchAgainstTableResolver(indexRegistry, mux.QueryPipeline) } // check whether exact index name is enabled @@ -71,7 +70,7 @@ func matchAgainstTableResolver(indexRegistry table_resolver.TableResolver, pipel return mux.MatchResult{Matched: false, Decision: decision} } for _, connector := range decision.UseConnectors { - if _, ok := connector.(*frontend_connectors.ConnectorDecisionClickhouse); ok { + if _, ok := connector.(*mux.ConnectorDecisionClickhouse); ok { return mux.MatchResult{Matched: true, Decision: decision} } } @@ -80,11 +79,11 @@ func matchAgainstTableResolver(indexRegistry table_resolver.TableResolver, pipel } func matchedExactQueryPath(indexRegistry table_resolver.TableResolver) mux.RequestMatcher { - return matchAgainstTableResolver(indexRegistry, frontend_connectors.QueryPipeline) + return matchAgainstTableResolver(indexRegistry, mux.QueryPipeline) } func matchedExactIngestPath(indexRegistry table_resolver.TableResolver) mux.RequestMatcher { - return matchAgainstTableResolver(indexRegistry, frontend_connectors.IngestPipeline) + return matchAgainstTableResolver(indexRegistry, mux.IngestPipeline) } // Returns false if the body contains a Kibana internal search. diff --git a/quesma/quesma/matchers_test.go b/quesma/quesma/matchers_test.go index 7fd52f98b..a45c0d85c 100644 --- a/quesma/quesma/matchers_test.go +++ b/quesma/quesma/matchers_test.go @@ -4,8 +4,8 @@ package quesma import ( "github.com/stretchr/testify/assert" - "quesma/frontend_connectors/mux" "quesma/quesma/types" + "quesma_v2/core/mux" "testing" ) diff --git a/quesma/quesma/processors.go b/quesma/quesma/processors.go index efb2b5092..2d9e9d7b9 100644 --- a/quesma/quesma/processors.go +++ b/quesma/quesma/processors.go @@ -4,8 +4,8 @@ package quesma import ( "context" - "quesma/frontend_connectors/mux" "quesma/tracing" + "quesma_v2/core/mux" ) type ( diff --git a/quesma/quesma/router.go b/quesma/quesma/router.go index b1a28e00c..4d681c95d 100644 --- a/quesma/quesma/router.go +++ b/quesma/quesma/router.go @@ -10,9 +10,6 @@ import ( "quesma/clickhouse" "quesma/elasticsearch" "quesma/end_user_errors" - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" - "quesma/frontend_connectors/routes" "quesma/ingest" "quesma/logger" "quesma/queryparser" @@ -29,6 +26,8 @@ import ( "quesma/table_resolver" "quesma/telemetry" "quesma/tracing" + "quesma_v2/core/mux" + "quesma_v2/core/routes" "regexp" "strings" "sync" @@ -384,7 +383,7 @@ func ConfigureRouter(cfg *config.QuesmaConfiguration, sr schema.Registry, lm *cl router.Register(routes.QuesmaTableResolverPath, method("GET"), func(ctx context.Context, req *mux.Request) (*mux.Result, error) { indexPattern := req.Params["index"] - decisions := make(map[string]*frontend_connectors.Decision) + decisions := make(map[string]*mux.Decision) humanReadable := make(map[string]string) for _, pipeline := range tableResolver.Pipelines() { decision := tableResolver.Resolve(pipeline, indexPattern) @@ -393,9 +392,9 @@ func ConfigureRouter(cfg *config.QuesmaConfiguration, sr schema.Registry, lm *cl } resp := struct { - IndexPattern string `json:"index_pattern"` - Decisions map[string]*frontend_connectors.Decision `json:"decisions"` - HumanReadable map[string]string `json:"human_readable"` + IndexPattern string `json:"index_pattern"` + Decisions map[string]*mux.Decision `json:"decisions"` + HumanReadable map[string]string `json:"human_readable"` }{ IndexPattern: indexPattern, Decisions: decisions, diff --git a/quesma/quesma/router_test.go b/quesma/quesma/router_test.go index 84820a898..4a6d9e480 100644 --- a/quesma/quesma/router_test.go +++ b/quesma/quesma/router_test.go @@ -6,15 +6,14 @@ import ( "fmt" "github.com/stretchr/testify/assert" "quesma/clickhouse" - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" - "quesma/frontend_connectors/routes" "quesma/ingest" "quesma/quesma/config" "quesma/quesma/ui" "quesma/schema" "quesma/table_resolver" "quesma/telemetry" + "quesma_v2/core/mux" + "quesma_v2/core/routes" "strings" "testing" ) @@ -359,15 +358,15 @@ func (t TestTableResolver) Start() {} func (t TestTableResolver) Stop() {} -func (t TestTableResolver) Resolve(_ string, indexPattern string) *frontend_connectors.Decision { +func (t TestTableResolver) Resolve(_ string, indexPattern string) *mux.Decision { if indexPattern == testIndexName { - return &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{ - &frontend_connectors.ConnectorDecisionClickhouse{}, + return &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{ + &mux.ConnectorDecisionClickhouse{}, }, } } else { - return &frontend_connectors.Decision{ + return &mux.Decision{ Err: fmt.Errorf("TestTableResolver err"), Reason: "TestTableResolver reason", ResolverName: "TestTableResolver", @@ -377,6 +376,6 @@ func (t TestTableResolver) Resolve(_ string, indexPattern string) *frontend_conn func (t TestTableResolver) Pipelines() []string { return []string{} } -func (t TestTableResolver) RecentDecisions() []frontend_connectors.PatternDecisions { - return []frontend_connectors.PatternDecisions{} +func (t TestTableResolver) RecentDecisions() []mux.PatternDecisions { + return []mux.PatternDecisions{} } diff --git a/quesma/quesma/router_v2.go b/quesma/quesma/router_v2.go index b5d208d35..e5cee199c 100644 --- a/quesma/quesma/router_v2.go +++ b/quesma/quesma/router_v2.go @@ -9,9 +9,6 @@ import ( "net/http" "quesma/clickhouse" "quesma/elasticsearch" - "quesma/frontend_connectors" - "quesma/frontend_connectors/mux" - "quesma/frontend_connectors/routes" "quesma/ingest" "quesma/logger" "quesma/queryparser" @@ -28,6 +25,8 @@ import ( "quesma/table_resolver" "quesma/telemetry" "quesma/tracing" + "quesma_v2/core/mux" + "quesma_v2/core/routes" "strings" "time" ) @@ -394,7 +393,7 @@ func ConfigureSearchRouterV2(cfg *config.QuesmaConfiguration, sr schema.Registry router.Register(routes.QuesmaTableResolverPath, method("GET"), func(ctx context.Context, req *mux.Request) (*mux.Result, error) { indexPattern := req.Params["index"] - decisions := make(map[string]*frontend_connectors.Decision) + decisions := make(map[string]*mux.Decision) humanReadable := make(map[string]string) for _, pipeline := range tableResolver.Pipelines() { decision := tableResolver.Resolve(pipeline, indexPattern) @@ -403,9 +402,9 @@ func ConfigureSearchRouterV2(cfg *config.QuesmaConfiguration, sr schema.Registry } resp := struct { - IndexPattern string `json:"index_pattern"` - Decisions map[string]*frontend_connectors.Decision `json:"decisions"` - HumanReadable map[string]string `json:"human_readable"` + IndexPattern string `json:"index_pattern"` + Decisions map[string]*mux.Decision `json:"decisions"` + HumanReadable map[string]string `json:"human_readable"` }{ IndexPattern: indexPattern, Decisions: decisions, diff --git a/quesma/quesma/search.go b/quesma/quesma/search.go index a0ee7a1da..dbf302323 100644 --- a/quesma/quesma/search.go +++ b/quesma/quesma/search.go @@ -12,7 +12,6 @@ import ( "quesma/common_table" "quesma/elasticsearch" "quesma/end_user_errors" - "quesma/frontend_connectors" "quesma/logger" "quesma/model" "quesma/optimize" @@ -29,6 +28,7 @@ import ( "quesma/telemetry" "quesma/tracing" "quesma/util" + "quesma_v2/core/mux" "strings" "sync/atomic" "time" @@ -102,9 +102,9 @@ func NewQueryRunnerDefaultForTests(db *sql.DB, cfg *config.QuesmaConfiguration, logChan := logger.InitOnlyChannelLoggerForTests() resolver := table_resolver.NewEmptyTableResolver() - resolver.Decisions[tableName] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{ - &frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions[tableName] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{ + &mux.ConnectorDecisionClickhouse{ ClickhouseTableName: tableName, ClickhouseTables: []string{tableName}, }, @@ -296,7 +296,7 @@ func (q *QueryRunner) executePlan(ctx context.Context, plan *model.ExecutionPlan func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern string, body types.JSON, optAsync *AsyncQuery, queryLanguage QueryLanguage) ([]byte, error) { - decision := q.tableResolver.Resolve(frontend_connectors.QueryPipeline, indexPattern) + decision := q.tableResolver.Resolve(mux.QueryPipeline, indexPattern) if decision.Err != nil { @@ -325,15 +325,15 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin return nil, end_user_errors.ErrSearchCondition.New(fmt.Errorf("no connectors to use")) } - var clickhouseConnector *frontend_connectors.ConnectorDecisionClickhouse + var clickhouseConnector *mux.ConnectorDecisionClickhouse for _, connector := range decision.UseConnectors { switch c := connector.(type) { - case *frontend_connectors.ConnectorDecisionClickhouse: + case *mux.ConnectorDecisionClickhouse: clickhouseConnector = c - case *frontend_connectors.ConnectorDecisionElastic: + case *mux.ConnectorDecisionElastic: // NOP default: diff --git a/quesma/quesma/search_ab_testing.go b/quesma/quesma/search_ab_testing.go index 7df9085b7..1a2db16a2 100644 --- a/quesma/quesma/search_ab_testing.go +++ b/quesma/quesma/search_ab_testing.go @@ -11,7 +11,6 @@ import ( "quesma/ab_testing" "quesma/clickhouse" "quesma/elasticsearch" - "quesma/frontend_connectors" "quesma/logger" "quesma/model" "quesma/quesma/async_search_storage" @@ -21,6 +20,7 @@ import ( "quesma/quesma/ui" "quesma/tracing" "quesma/util" + "quesma_v2/core/mux" "time" ) @@ -112,7 +112,7 @@ func (q *QueryRunner) runABTestingResultsCollector(ctx context.Context, indexPat return optComparePlansCh, backgroundContext } -func (q *QueryRunner) executeABTesting(ctx context.Context, plan *model.ExecutionPlan, queryTranslator IQueryTranslator, table *clickhouse.Table, body types.JSON, optAsync *AsyncQuery, decision *frontend_connectors.Decision, indexPattern string) ([]byte, error) { +func (q *QueryRunner) executeABTesting(ctx context.Context, plan *model.ExecutionPlan, queryTranslator IQueryTranslator, table *clickhouse.Table, body types.JSON, optAsync *AsyncQuery, decision *mux.Decision, indexPattern string) ([]byte, error) { optComparePlansCh, backgroundContext := q.runABTestingResultsCollector(ctx, indexPattern, body) @@ -126,13 +126,13 @@ func (q *QueryRunner) executeABTesting(ctx context.Context, plan *model.Executio switch connector.(type) { - case *frontend_connectors.ConnectorDecisionClickhouse: + case *mux.ConnectorDecisionClickhouse: planExecutor = func(ctx context.Context) ([]byte, error) { plan.Name = config.ClickhouseTarget return q.executePlan(ctx, plan, queryTranslator, table, body, optAsync, optComparePlansCh, isMainPlan) } - case *frontend_connectors.ConnectorDecisionElastic: + case *mux.ConnectorDecisionElastic: planExecutor = func(ctx context.Context) ([]byte, error) { elasticPlan := &model.ExecutionPlan{ IndexPattern: plan.IndexPattern, diff --git a/quesma/quesma/search_common_table_test.go b/quesma/quesma/search_common_table_test.go index b25b5c052..1adde07c6 100644 --- a/quesma/quesma/search_common_table_test.go +++ b/quesma/quesma/search_common_table_test.go @@ -9,7 +9,6 @@ import ( "quesma/clickhouse" "quesma/common_table" "quesma/elasticsearch" - "quesma/frontend_connectors" "quesma/logger" "quesma/quesma/config" "quesma/quesma/types" @@ -17,6 +16,7 @@ import ( "quesma/schema" "quesma/table_resolver" "quesma/telemetry" + "quesma_v2/core/mux" "testing" ) @@ -251,47 +251,47 @@ func TestSearchCommonTable(t *testing.T) { resolver := table_resolver.NewEmptyTableResolver() - resolver.Decisions["logs-1"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["logs-1"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"logs-1"}, IsCommonTable: true, }}, } - resolver.Decisions["logs-2"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["logs-2"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"logs-2"}, IsCommonTable: true, }}, } - resolver.Decisions["logs-3"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["logs-3"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "logs-3", ClickhouseTables: []string{"logs-3"}, IsCommonTable: false, }}, } - resolver.Decisions["logs-1,logs-2"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["logs-1,logs-2"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"logs-1", "logs-2"}, IsCommonTable: true, }}, } - resolver.Decisions["logs-*"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["logs-*"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"logs-1", "logs-2"}, IsCommonTable: true, }}, } - resolver.Decisions["*"] = &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + resolver.Decisions["*"] = &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"logs-1", "logs-2"}, IsCommonTable: true, diff --git a/quesma/quesma/types/request_body.go b/quesma/quesma/types/request_body.go index 27e345c7f..479b9c9f0 100644 --- a/quesma/quesma/types/request_body.go +++ b/quesma/quesma/types/request_body.go @@ -5,6 +5,7 @@ package types import ( "fmt" "quesma/end_user_errors" + "quesma_v2/core/mux" "strings" ) @@ -22,15 +23,11 @@ func (u *Unknown) String() string { } -type RequestBody interface { - isParsedRequestBody() // this is a marker method -} - -func (j JSON) isParsedRequestBody() {} -func (n NDJSON) isParsedRequestBody() {} -func (u *Unknown) isParsedRequestBody() {} +func (j JSON) IsParsedRequestBody() {} +func (n NDJSON) IsParsedRequestBody() {} +func (u *Unknown) IsParsedRequestBody() {} -func ParseRequestBody(body string) RequestBody { +func ParseRequestBody(body string) mux.RequestBody { unknow := &Unknown{} unknow.Body = body @@ -63,7 +60,7 @@ func ParseRequestBody(body string) RequestBody { return unknow } -func ExpectJSON(body RequestBody) (JSON, error) { +func ExpectJSON(body mux.RequestBody) (JSON, error) { switch b := body.(type) { case JSON: @@ -73,7 +70,7 @@ func ExpectJSON(body RequestBody) (JSON, error) { } } -func ExpectNDJSON(body RequestBody) (NDJSON, error) { +func ExpectNDJSON(body mux.RequestBody) (NDJSON, error) { switch b := body.(type) { case NDJSON: diff --git a/quesma/quesma/ui/routing.go b/quesma/quesma/ui/routing.go index b3a1aba9c..6fafbfd49 100644 --- a/quesma/quesma/ui/routing.go +++ b/quesma/quesma/ui/routing.go @@ -3,8 +3,8 @@ package ui import ( - "quesma/frontend_connectors/mux" "quesma/quesma/ui/internal/builder" + "quesma_v2/core/mux" "strings" ) diff --git a/quesma/table_resolver/empty.go b/quesma/table_resolver/empty.go index e83838973..4a4fa07f1 100644 --- a/quesma/table_resolver/empty.go +++ b/quesma/table_resolver/empty.go @@ -4,35 +4,35 @@ package table_resolver import ( "fmt" - "quesma/frontend_connectors" + "quesma_v2/core/mux" ) type EmptyTableResolver struct { - Decisions map[string]*frontend_connectors.Decision - RecentDecisionList []frontend_connectors.PatternDecisions + Decisions map[string]*mux.Decision + RecentDecisionList []mux.PatternDecisions PipelinesList []string } func NewEmptyTableResolver() *EmptyTableResolver { return &EmptyTableResolver{ - Decisions: make(map[string]*frontend_connectors.Decision), + Decisions: make(map[string]*mux.Decision), } } -func (r *EmptyTableResolver) Resolve(pipeline string, indexPattern string) *frontend_connectors.Decision { +func (r *EmptyTableResolver) Resolve(pipeline string, indexPattern string) *mux.Decision { d, ok := r.Decisions[indexPattern] if ok { return d } msg := fmt.Sprintf("Could not resolve pattern %v. Fix you test setup first.", indexPattern) - return &frontend_connectors.Decision{ + return &mux.Decision{ Err: fmt.Errorf("%s", msg), Reason: msg, ResolverName: "EmptyTableResolver.Resolve", } } -func (r *EmptyTableResolver) RecentDecisions() []frontend_connectors.PatternDecisions { +func (r *EmptyTableResolver) RecentDecisions() []mux.PatternDecisions { return r.RecentDecisionList } diff --git a/quesma/table_resolver/model.go b/quesma/table_resolver/model.go index 5eeaf4548..edeaac4a6 100644 --- a/quesma/table_resolver/model.go +++ b/quesma/table_resolver/model.go @@ -2,14 +2,16 @@ // SPDX-License-Identifier: Elastic-2.0 package table_resolver -import "quesma/frontend_connectors" +import ( + "quesma_v2/core/mux" +) type TableResolver interface { Start() Stop() - Resolve(pipeline string, indexPattern string) *frontend_connectors.Decision + Resolve(pipeline string, indexPattern string) *mux.Decision Pipelines() []string - RecentDecisions() []frontend_connectors.PatternDecisions + RecentDecisions() []mux.PatternDecisions } diff --git a/quesma/table_resolver/rules.go b/quesma/table_resolver/rules.go index 495b3ba04..c76292098 100644 --- a/quesma/table_resolver/rules.go +++ b/quesma/table_resolver/rules.go @@ -7,9 +7,9 @@ import ( "quesma/common_table" "quesma/elasticsearch" "quesma/end_user_errors" - "quesma/frontend_connectors" "quesma/quesma/config" "quesma/util" + "quesma_v2/core/mux" "reflect" "strings" ) @@ -17,7 +17,7 @@ import ( // TODO these rules may be incorrect and incomplete // They will be fixed int the next iteration. -func (r *tableRegistryImpl) wildcardPatternSplitter(pattern string) (parsedPattern, *frontend_connectors.Decision) { +func (r *tableRegistryImpl) wildcardPatternSplitter(pattern string) (parsedPattern, *mux.Decision) { patterns := strings.Split(pattern, ",") // Given a (potentially wildcard) pattern, find all non-wildcard index names that match the pattern @@ -62,10 +62,10 @@ func (r *tableRegistryImpl) wildcardPatternSplitter(pattern string) (parsedPatte }, nil } -func singleIndexSplitter(pattern string) (parsedPattern, *frontend_connectors.Decision) { +func singleIndexSplitter(pattern string) (parsedPattern, *mux.Decision) { patterns := strings.Split(pattern, ",") if len(patterns) > 1 || strings.Contains(pattern, "*") { - return parsedPattern{}, &frontend_connectors.Decision{ + return parsedPattern{}, &mux.Decision{ Reason: "Pattern is not allowed.", Err: fmt.Errorf("pattern is not allowed"), } @@ -78,13 +78,13 @@ func singleIndexSplitter(pattern string) (parsedPattern, *frontend_connectors.De }, nil } -func makeIsDisabledInConfig(cfg map[string]config.IndexConfiguration, pipeline string) func(part string) *frontend_connectors.Decision { +func makeIsDisabledInConfig(cfg map[string]config.IndexConfiguration, pipeline string) func(part string) *mux.Decision { - return func(part string) *frontend_connectors.Decision { + return func(part string) *mux.Decision { idx, ok := cfg[part] if ok { if len(getTargets(idx, pipeline)) == 0 { - return &frontend_connectors.Decision{ + return &mux.Decision{ IsClosed: true, Reason: "Index is disabled in config.", } @@ -95,11 +95,11 @@ func makeIsDisabledInConfig(cfg map[string]config.IndexConfiguration, pipeline s } } -func resolveInternalElasticName(part string) *frontend_connectors.Decision { +func resolveInternalElasticName(part string) *mux.Decision { if elasticsearch.IsInternalIndex(part) { - return &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{ManagementCall: true}}, + return &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{ManagementCall: true}}, Reason: "It's kibana internals", } } @@ -107,18 +107,18 @@ func resolveInternalElasticName(part string) *frontend_connectors.Decision { return nil } -func makeDefaultWildcard(quesmaConf config.QuesmaConfiguration, pipeline string) func(part string) *frontend_connectors.Decision { - return func(part string) *frontend_connectors.Decision { +func makeDefaultWildcard(quesmaConf config.QuesmaConfiguration, pipeline string) func(part string) *mux.Decision { + return func(part string) *mux.Decision { var targets []string - var useConnectors []frontend_connectors.ConnectorDecision + var useConnectors []mux.ConnectorDecision switch pipeline { - case frontend_connectors.IngestPipeline: + case mux.IngestPipeline: targets = quesmaConf.DefaultIngestTarget - case frontend_connectors.QueryPipeline: + case mux.QueryPipeline: targets = quesmaConf.DefaultQueryTarget default: - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("unsupported pipeline: %s", pipeline)), } @@ -127,22 +127,22 @@ func makeDefaultWildcard(quesmaConf config.QuesmaConfiguration, pipeline string) for _, target := range targets { switch target { case config.ClickhouseTarget: - useConnectors = append(useConnectors, &frontend_connectors.ConnectorDecisionClickhouse{ + useConnectors = append(useConnectors, &mux.ConnectorDecisionClickhouse{ ClickhouseTableName: part, IsCommonTable: quesmaConf.UseCommonTableForWildcard, ClickhouseTables: []string{part}, }) case config.ElasticsearchTarget: - useConnectors = append(useConnectors, &frontend_connectors.ConnectorDecisionElastic{}) + useConnectors = append(useConnectors, &mux.ConnectorDecisionElastic{}) default: - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("unsupported target: %s", target)), } } } - return &frontend_connectors.Decision{ + return &mux.Decision{ UseConnectors: useConnectors, IsClosed: len(useConnectors) == 0, Reason: fmt.Sprintf("Using default wildcard ('%s') configuration for %s processor", config.DefaultWildcardIndexName, pipeline), @@ -150,9 +150,9 @@ func makeDefaultWildcard(quesmaConf config.QuesmaConfiguration, pipeline string) } } -func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfiguration, pipeline string) func(part string) *frontend_connectors.Decision { +func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfiguration, pipeline string) func(part string) *mux.Decision { - return func(part string) *frontend_connectors.Decision { + return func(part string) *mux.Decision { if cfg, ok := indexConfig[part]; ok { if !cfg.UseCommonTable { @@ -164,23 +164,23 @@ func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfi case 1: - decision := &frontend_connectors.Decision{ + decision := &mux.Decision{ Reason: "Enabled in the config. ", } - var targetDecision frontend_connectors.ConnectorDecision + var targetDecision mux.ConnectorDecision switch targets[0] { case config.ElasticsearchTarget: - targetDecision = &frontend_connectors.ConnectorDecisionElastic{} + targetDecision = &mux.ConnectorDecisionElastic{} case config.ClickhouseTarget: - targetDecision = &frontend_connectors.ConnectorDecisionClickhouse{ + targetDecision = &mux.ConnectorDecisionClickhouse{ ClickhouseTableName: part, ClickhouseTables: []string{part}, } default: - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("unsupported target: %s", targets[0])), } @@ -192,36 +192,36 @@ func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfi switch pipeline { - case frontend_connectors.IngestPipeline: - return &frontend_connectors.Decision{ + case mux.IngestPipeline: + return &mux.Decision{ Reason: "Enabled in the config. Dual write is enabled.", - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: part, ClickhouseTables: []string{part}}, - &frontend_connectors.ConnectorDecisionElastic{}}, + &mux.ConnectorDecisionElastic{}}, } - case frontend_connectors.QueryPipeline: + case mux.QueryPipeline: if targets[0] == config.ClickhouseTarget && targets[1] == config.ElasticsearchTarget { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Enabled in the config. A/B testing.", EnableABTesting: true, - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: part, ClickhouseTables: []string{part}}, - &frontend_connectors.ConnectorDecisionElastic{}}, + &mux.ConnectorDecisionElastic{}}, } } else if targets[0] == config.ElasticsearchTarget && targets[1] == config.ClickhouseTarget { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Enabled in the config. A/B testing.", EnableABTesting: true, - UseConnectors: []frontend_connectors.ConnectorDecision{ - &frontend_connectors.ConnectorDecisionElastic{}, - &frontend_connectors.ConnectorDecisionClickhouse{ + UseConnectors: []mux.ConnectorDecision{ + &mux.ConnectorDecisionElastic{}, + &mux.ConnectorDecisionClickhouse{ ClickhouseTableName: part, ClickhouseTables: []string{part}}, }, @@ -230,19 +230,19 @@ func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfi } default: - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("unsupported pipeline: %s", pipeline)), } } - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("unsupported configuration for pipeline %s, targets: %v", pipeline, targets)), } default: - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Unsupported configuration", Err: end_user_errors.ErrSearchCondition.New(fmt.Errorf("too many backend connector")), } @@ -254,11 +254,11 @@ func (r *tableRegistryImpl) singleIndex(indexConfig map[string]config.IndexConfi } } -func (r *tableRegistryImpl) makeCommonTableResolver(cfg map[string]config.IndexConfiguration, pipeline string) func(part string) *frontend_connectors.Decision { +func (r *tableRegistryImpl) makeCommonTableResolver(cfg map[string]config.IndexConfiguration, pipeline string) func(part string) *mux.Decision { - return func(part string) *frontend_connectors.Decision { + return func(part string) *mux.Decision { if part == common_table.TableName { - return &frontend_connectors.Decision{ + return &mux.Decision{ Err: fmt.Errorf("common table is not allowed to be queried directly"), Reason: "It's internal table. Not allowed to be queried directly.", } @@ -276,8 +276,8 @@ func (r *tableRegistryImpl) makeCommonTableResolver(cfg map[string]config.IndexC } if idxConfig, ok := cfg[part]; (ok && idxConfig.UseCommonTable) || (virtualTableExists) { - return &frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + return &mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{part}, IsCommonTable: true, @@ -290,26 +290,26 @@ func (r *tableRegistryImpl) makeCommonTableResolver(cfg map[string]config.IndexC } } -func mergeUseConnectors(lhs []frontend_connectors.ConnectorDecision, rhs []frontend_connectors.ConnectorDecision, rhsIndexName string) ([]frontend_connectors.ConnectorDecision, *frontend_connectors.Decision) { +func mergeUseConnectors(lhs []mux.ConnectorDecision, rhs []mux.ConnectorDecision, rhsIndexName string) ([]mux.ConnectorDecision, *mux.Decision) { for _, connDecisionRhs := range rhs { foundMatching := false for _, connDecisionLhs := range lhs { - if _, ok := connDecisionRhs.(*frontend_connectors.ConnectorDecisionElastic); ok { - if _, ok := connDecisionLhs.(*frontend_connectors.ConnectorDecisionElastic); ok { + if _, ok := connDecisionRhs.(*mux.ConnectorDecisionElastic); ok { + if _, ok := connDecisionLhs.(*mux.ConnectorDecisionElastic); ok { foundMatching = true } } - if rhsClickhouse, ok := connDecisionRhs.(*frontend_connectors.ConnectorDecisionClickhouse); ok { - if lhsClickhouse, ok := connDecisionLhs.(*frontend_connectors.ConnectorDecisionClickhouse); ok { + if rhsClickhouse, ok := connDecisionRhs.(*mux.ConnectorDecisionClickhouse); ok { + if lhsClickhouse, ok := connDecisionLhs.(*mux.ConnectorDecisionClickhouse); ok { if lhsClickhouse.ClickhouseTableName != rhsClickhouse.ClickhouseTableName { - return nil, &frontend_connectors.Decision{ + return nil, &mux.Decision{ Reason: "Incompatible decisions for two indexes - they use a different ClickHouse table", Err: fmt.Errorf("incompatible decisions for two indexes (different ClickHouse table) - %s and %s", connDecisionRhs, connDecisionLhs), } } if lhsClickhouse.IsCommonTable { if !rhsClickhouse.IsCommonTable { - return nil, &frontend_connectors.Decision{ + return nil, &mux.Decision{ Reason: "Incompatible decisions for two indexes - one uses the common table, the other does not", Err: fmt.Errorf("incompatible decisions for two indexes (common table usage) - %s and %s", connDecisionRhs, connDecisionLhs), } @@ -318,7 +318,7 @@ func mergeUseConnectors(lhs []frontend_connectors.ConnectorDecision, rhs []front lhsClickhouse.ClickhouseTables = util.Distinct(lhsClickhouse.ClickhouseTables) } else { if !reflect.DeepEqual(lhsClickhouse, rhsClickhouse) { - return nil, &frontend_connectors.Decision{ + return nil, &mux.Decision{ Reason: "Incompatible decisions for two indexes - they use ClickHouse tables differently", Err: fmt.Errorf("incompatible decisions for two indexes (different usage of ClickHouse) - %s and %s", connDecisionRhs, connDecisionLhs), } @@ -329,7 +329,7 @@ func mergeUseConnectors(lhs []frontend_connectors.ConnectorDecision, rhs []front } } if !foundMatching { - return nil, &frontend_connectors.Decision{ + return nil, &mux.Decision{ Reason: "Incompatible decisions for two indexes - they use different connectors", Err: fmt.Errorf("incompatible decisions for two indexes - they use different connectors: could not find connector %s used for index %s in decisions: %s", connDecisionRhs, rhsIndexName, lhs), } @@ -339,9 +339,9 @@ func mergeUseConnectors(lhs []frontend_connectors.ConnectorDecision, rhs []front return lhs, nil } -func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_connectors.Decision { +func basicDecisionMerger(decisions []*mux.Decision) *mux.Decision { if len(decisions) == 0 { - return &frontend_connectors.Decision{ + return &mux.Decision{ IsEmpty: true, Reason: "No indexes matched, no decisions made.", } @@ -352,7 +352,7 @@ func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_co for _, decision := range decisions { if decision == nil { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Got a nil decision. This is a bug.", Err: fmt.Errorf("could not resolve index"), } @@ -363,21 +363,21 @@ func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_co } if decision.IsEmpty { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Got an empty decision. This is a bug.", Err: fmt.Errorf("could not resolve index, empty index: %s", decision.IndexPattern), } } if decision.EnableABTesting != decisions[0].EnableABTesting { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "One of the indexes matching the pattern does A/B testing, while another index does not - inconsistency.", Err: fmt.Errorf("inconsistent A/B testing configuration - index %s (A/B testing: %v) and index %s (A/B testing: %v)", decision.IndexPattern, decision.EnableABTesting, decisions[0].IndexPattern, decisions[0].EnableABTesting), } } } - var nonClosedDecisions []*frontend_connectors.Decision + var nonClosedDecisions []*mux.Decision for _, decision := range decisions { if !decision.IsClosed { nonClosedDecisions = append(nonClosedDecisions, decision) @@ -385,7 +385,7 @@ func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_co } if len(nonClosedDecisions) == 0 { // All indexes are closed - return &frontend_connectors.Decision{ + return &mux.Decision{ IsClosed: true, Reason: "All indexes matching the pattern are closed.", } @@ -400,7 +400,7 @@ func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_co continue } if len(decision.UseConnectors) != len(decisions[0].UseConnectors) { - return &frontend_connectors.Decision{ + return &mux.Decision{ Reason: "Inconsistent number of connectors", Err: fmt.Errorf("inconsistent number of connectors - index %s (%d connectors) and index %s (%d connectors)", decision.IndexPattern, len(decision.UseConnectors), decisions[0].IndexPattern, len(decisions[0].UseConnectors)), } @@ -413,7 +413,7 @@ func basicDecisionMerger(decisions []*frontend_connectors.Decision) *frontend_co useConnectors = newUseConnectors } - return &frontend_connectors.Decision{ + return &mux.Decision{ UseConnectors: useConnectors, EnableABTesting: decisions[0].EnableABTesting, Reason: "Merged decisions", diff --git a/quesma/table_resolver/table_resolver.go b/quesma/table_resolver/table_resolver.go index afb115249..1f29e0e37 100644 --- a/quesma/table_resolver/table_resolver.go +++ b/quesma/table_resolver/table_resolver.go @@ -7,17 +7,17 @@ import ( "fmt" "quesma/clickhouse" "quesma/elasticsearch" - "quesma/frontend_connectors" "quesma/logger" "quesma/quesma/config" "quesma/quesma/recovery" + "quesma_v2/core/mux" "sort" "sync" "time" ) type tableResolver interface { - resolve(indexPattern string) *frontend_connectors.Decision + resolve(indexPattern string) *mux.Decision } // parsedPattern stores the parsed index pattern @@ -32,17 +32,17 @@ type parsedPattern struct { type patternSplitter struct { name string - resolver func(pattern string) (parsedPattern, *frontend_connectors.Decision) + resolver func(pattern string) (parsedPattern, *mux.Decision) } type basicResolver struct { name string - resolver func(part string) *frontend_connectors.Decision + resolver func(part string) *mux.Decision } type decisionMerger struct { name string - merger func(decisions []*frontend_connectors.Decision) *frontend_connectors.Decision + merger func(decisions []*mux.Decision) *mux.Decision } // Compound resolver works in the following way: @@ -55,14 +55,14 @@ type compoundResolver struct { decisionMerger decisionMerger } -func (ir *compoundResolver) resolve(indexName string) *frontend_connectors.Decision { +func (ir *compoundResolver) resolve(indexName string) *mux.Decision { input, decision := ir.patternSplitter.resolver(indexName) if decision != nil { decision.ResolverName = ir.patternSplitter.name return decision } - var decisions []*frontend_connectors.Decision + var decisions []*mux.Decision for _, part := range input.parts { for _, resolver := range ir.decisionLadder { decision := resolver.resolver(part) @@ -82,9 +82,9 @@ func (ir *compoundResolver) resolve(indexName string) *frontend_connectors.Decis // now we have a single config for both, but with different fields func getTargets(indexConf config.IndexConfiguration, pipeline string) []string { switch pipeline { - case frontend_connectors.IngestPipeline: + case mux.IngestPipeline: return indexConf.IngestTarget - case frontend_connectors.QueryPipeline: + case mux.QueryPipeline: return indexConf.QueryTarget default: return []string{} @@ -101,7 +101,7 @@ type pipelineResolver struct { pipelineName string resolver tableResolver - recentDecisions map[string]*frontend_connectors.Decision + recentDecisions map[string]*mux.Decision } type tableRegistryImpl struct { @@ -119,13 +119,13 @@ type tableRegistryImpl struct { conf config.QuesmaConfiguration } -func (r *tableRegistryImpl) Resolve(pipeline string, indexPattern string) *frontend_connectors.Decision { +func (r *tableRegistryImpl) Resolve(pipeline string, indexPattern string) *mux.Decision { r.m.Lock() defer r.m.Unlock() res, exists := r.pipelineResolvers[pipeline] if !exists { - return &frontend_connectors.Decision{ + return &mux.Decision{ IndexPattern: indexPattern, Err: fmt.Errorf("pipeline '%s' not found", pipeline), Reason: "Pipeline not found. This is a bug.", @@ -195,7 +195,7 @@ func (r *tableRegistryImpl) updateIndexes() { r.elasticIndexes = elasticIndexes r.clickhouseIndexes = clickhouseIndexes for _, res := range r.pipelineResolvers { - res.recentDecisions = make(map[string]*frontend_connectors.Decision) + res.recentDecisions = make(map[string]*mux.Decision) } } @@ -224,7 +224,7 @@ func (r *tableRegistryImpl) Start() { }() } -func (r *tableRegistryImpl) RecentDecisions() []frontend_connectors.PatternDecisions { +func (r *tableRegistryImpl) RecentDecisions() []mux.PatternDecisions { r.m.Lock() defer r.m.Unlock() @@ -243,12 +243,12 @@ func (r *tableRegistryImpl) RecentDecisions() []frontend_connectors.PatternDecis sort.Strings(patterns) - var res []frontend_connectors.PatternDecisions + var res []mux.PatternDecisions for _, p := range patterns { - pd := frontend_connectors.PatternDecisions{ + pd := mux.PatternDecisions{ Pattern: p, - Decisions: make(map[string]*frontend_connectors.Decision), + Decisions: make(map[string]*mux.Decision), } for _, resolver := range r.pipelineResolvers { if decision, ok := resolver.recentDecisions[p]; ok { @@ -296,7 +296,7 @@ func NewTableResolver(quesmaConf config.QuesmaConfiguration, discovery clickhous // TODO We should use the pipeline name as a key in the map. ingestResolver := &pipelineResolver{ - pipelineName: frontend_connectors.IngestPipeline, + pipelineName: mux.IngestPipeline, resolver: &compoundResolver{ patternSplitter: patternSplitter{ @@ -305,25 +305,25 @@ func NewTableResolver(quesmaConf config.QuesmaConfiguration, discovery clickhous }, decisionLadder: []basicResolver{ {"kibanaInternal", resolveInternalElasticName}, - {"disabled", makeIsDisabledInConfig(indexConf, frontend_connectors.IngestPipeline)}, + {"disabled", makeIsDisabledInConfig(indexConf, mux.IngestPipeline)}, - {"singleIndex", res.singleIndex(indexConf, frontend_connectors.IngestPipeline)}, - {"commonTable", res.makeCommonTableResolver(indexConf, frontend_connectors.IngestPipeline)}, + {"singleIndex", res.singleIndex(indexConf, mux.IngestPipeline)}, + {"commonTable", res.makeCommonTableResolver(indexConf, mux.IngestPipeline)}, - {"defaultWildcard", makeDefaultWildcard(quesmaConf, frontend_connectors.IngestPipeline)}, + {"defaultWildcard", makeDefaultWildcard(quesmaConf, mux.IngestPipeline)}, }, decisionMerger: decisionMerger{ name: "basicDecisionMerger", merger: basicDecisionMerger, }, }, - recentDecisions: make(map[string]*frontend_connectors.Decision), + recentDecisions: make(map[string]*mux.Decision), } - res.pipelineResolvers[frontend_connectors.IngestPipeline] = ingestResolver + res.pipelineResolvers[mux.IngestPipeline] = ingestResolver queryResolver := &pipelineResolver{ - pipelineName: frontend_connectors.QueryPipeline, + pipelineName: mux.QueryPipeline, resolver: &compoundResolver{ patternSplitter: patternSplitter{ @@ -333,23 +333,23 @@ func NewTableResolver(quesmaConf config.QuesmaConfiguration, discovery clickhous decisionLadder: []basicResolver{ // checking if we can handle the parsedPattern {"kibanaInternal", resolveInternalElasticName}, - {"disabled", makeIsDisabledInConfig(indexConf, frontend_connectors.QueryPipeline)}, + {"disabled", makeIsDisabledInConfig(indexConf, mux.QueryPipeline)}, - {"singleIndex", res.singleIndex(indexConf, frontend_connectors.QueryPipeline)}, - {"commonTable", res.makeCommonTableResolver(indexConf, frontend_connectors.QueryPipeline)}, + {"singleIndex", res.singleIndex(indexConf, mux.QueryPipeline)}, + {"commonTable", res.makeCommonTableResolver(indexConf, mux.QueryPipeline)}, // default action - {"defaultWildcard", makeDefaultWildcard(quesmaConf, frontend_connectors.QueryPipeline)}, + {"defaultWildcard", makeDefaultWildcard(quesmaConf, mux.QueryPipeline)}, }, decisionMerger: decisionMerger{ name: "basicDecisionMerger", merger: basicDecisionMerger, }, }, - recentDecisions: make(map[string]*frontend_connectors.Decision), + recentDecisions: make(map[string]*mux.Decision), } - res.pipelineResolvers[frontend_connectors.QueryPipeline] = queryResolver + res.pipelineResolvers[mux.QueryPipeline] = queryResolver // update the state ASAP res.updateState() return res diff --git a/quesma/table_resolver/table_resolver_test.go b/quesma/table_resolver/table_resolver_test.go index 1ccee5567..23ad361f9 100644 --- a/quesma/table_resolver/table_resolver_test.go +++ b/quesma/table_resolver/table_resolver_test.go @@ -9,8 +9,8 @@ import ( "quesma/clickhouse" "quesma/common_table" "quesma/elasticsearch" - "quesma/frontend_connectors" "quesma/quesma/config" + "quesma_v2/core/mux" "reflect" "strings" "testing" @@ -65,105 +65,105 @@ func TestTableResolver(t *testing.T) { clickhouseIndexes []string virtualTables []string indexConf map[string]config.IndexConfiguration - expected frontend_connectors.Decision + expected mux.Decision }{ { name: "elastic fallback", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "some-index", - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{}}, }, indexConf: make(map[string]config.IndexConfiguration), }, { name: "all", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "*", - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf("inconsistent A/B testing configuration"), }, indexConf: indexConf, }, { name: "empty *", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "*", clickhouseIndexes: []string{"index1", "index2"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf(""), }, indexConf: indexConf, }, { name: "query all, indices in both connectors", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "*", clickhouseIndexes: []string{"index1", "index2"}, elasticIndexes: []string{"index3"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf(""), }, indexConf: indexConf, }, { name: "ingest with a pattern", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "*", clickhouseIndexes: []string{"index1", "index2"}, elasticIndexes: []string{"index3"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf("pattern is not allowed"), }, indexConf: indexConf, }, { name: "query closed index", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "closed", clickhouseIndexes: []string{"closed"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ IsClosed: true, }, indexConf: indexConf, }, { name: "ingest closed index", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "closed", clickhouseIndexes: []string{"closed"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ IsClosed: true, }, indexConf: indexConf, }, { name: "ingest closed index", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "closed-common-table", clickhouseIndexes: []string{"closed"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ IsClosed: true, }, indexConf: indexConf, }, { name: "ingest closed index", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "unknown-target", clickhouseIndexes: []string{"closed"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf("unsupported target"), }, indexConf: indexConf, }, { name: "ingest to index1", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "index1", clickhouseIndexes: []string{"index1"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "index1", ClickhouseTables: []string{"index1"}}, }, @@ -172,11 +172,11 @@ func TestTableResolver(t *testing.T) { }, { name: "query from index1", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index1", clickhouseIndexes: []string{"index1"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "index1", ClickhouseTables: []string{"index1"}}, }, @@ -185,11 +185,11 @@ func TestTableResolver(t *testing.T) { }, { name: "ingest to index2", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "index2", clickhouseIndexes: []string{"index2"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"index2"}, IsCommonTable: true, @@ -199,11 +199,11 @@ func TestTableResolver(t *testing.T) { }, { name: "query from index2", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index2", clickhouseIndexes: []string{"index2"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"index2"}, IsCommonTable: true, @@ -213,52 +213,52 @@ func TestTableResolver(t *testing.T) { }, { name: "query from index1,index2", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index1,index2", elasticIndexes: []string{"index3"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf(""), }, indexConf: indexConf, }, { name: "query from index1,index-not-existing", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index1,index-not-existing", elasticIndexes: []string{"index1,index-not-existing"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf(""), // index1 in Clickhouse, index-not-existing in Elastic ('*') }, indexConf: indexConf, }, { name: "ingest to index3", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "index3", elasticIndexes: []string{"index3"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "query from index3", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index3", elasticIndexes: []string{"index3"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "query pattern", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "index2,foo*", virtualTables: []string{"index2"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: common_table.TableName, ClickhouseTables: []string{"index2"}, IsCommonTable: true, @@ -268,108 +268,108 @@ func TestTableResolver(t *testing.T) { }, { name: "query kibana internals", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: ".kibana", - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{ManagementCall: true}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{ManagementCall: true}}, }, indexConf: indexConf, }, { name: "ingest kibana internals", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: ".kibana", - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{ManagementCall: true}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{ManagementCall: true}}, }, indexConf: indexConf, }, { name: "ingest not configured index", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "not-configured", - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{}}, + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "double write", - pipeline: frontend_connectors.IngestPipeline, + pipeline: mux.IngestPipeline, pattern: "logs", - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "logs", ClickhouseTables: []string{"logs"}, }, - &frontend_connectors.ConnectorDecisionElastic{}}, + &mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "A/B testing", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "logs", - expected: frontend_connectors.Decision{ + expected: mux.Decision{ EnableABTesting: true, - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "logs", ClickhouseTables: []string{"logs"}, }, - &frontend_connectors.ConnectorDecisionElastic{}}, + &mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "A/B testing (pattern)", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "logs*", - expected: frontend_connectors.Decision{ + expected: mux.Decision{ EnableABTesting: true, - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionClickhouse{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionClickhouse{ ClickhouseTableName: "logs", ClickhouseTables: []string{"logs"}, }, - &frontend_connectors.ConnectorDecisionElastic{}}, + &mux.ConnectorDecisionElastic{}}, }, indexConf: indexConf, }, { name: "query both connectors", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "logs,index1", indexConf: indexConf, clickhouseIndexes: []string{"index1"}, elasticIndexes: []string{"logs"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf(""), }, }, { name: "query elastic with pattern", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "some-elastic-logs*", elasticIndexes: []string{"logs"}, - expected: frontend_connectors.Decision{ - UseConnectors: []frontend_connectors.ConnectorDecision{&frontend_connectors.ConnectorDecisionElastic{ + expected: mux.Decision{ + UseConnectors: []mux.ConnectorDecision{&mux.ConnectorDecisionElastic{ ManagementCall: false, }}, }, }, { name: "non matching pattern", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "some-non-matching-pattern*", elasticIndexes: []string{"logs"}, - expected: frontend_connectors.Decision{ + expected: mux.Decision{ IsEmpty: true, }, }, { name: "query internal index", - pipeline: frontend_connectors.QueryPipeline, + pipeline: mux.QueryPipeline, pattern: "quesma_common_table", - expected: frontend_connectors.Decision{ + expected: mux.Decision{ Err: fmt.Errorf("common table"), }, }, diff --git a/quesma/frontend_connectors/decision.go b/quesma/v2/core/mux/decision.go similarity index 98% rename from quesma/frontend_connectors/decision.go rename to quesma/v2/core/mux/decision.go index e386693d9..a717a0160 100644 --- a/quesma/frontend_connectors/decision.go +++ b/quesma/v2/core/mux/decision.go @@ -1,6 +1,6 @@ // Copyright Quesma, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -package frontend_connectors +package mux import ( "fmt" diff --git a/quesma/frontend_connectors/mux/match_history.go b/quesma/v2/core/mux/match_history.go similarity index 98% rename from quesma/frontend_connectors/mux/match_history.go rename to quesma/v2/core/mux/match_history.go index 94660e2e1..05d46fe82 100644 --- a/quesma/frontend_connectors/mux/match_history.go +++ b/quesma/v2/core/mux/match_history.go @@ -3,7 +3,7 @@ package mux import ( - "quesma/frontend_connectors/routes" + "quesma_v2/core/routes" "slices" "strings" "sync" diff --git a/quesma/frontend_connectors/mux/mux.go b/quesma/v2/core/mux/mux.go similarity index 86% rename from quesma/frontend_connectors/mux/mux.go rename to quesma/v2/core/mux/mux.go index 69e6007ee..92c337c69 100644 --- a/quesma/frontend_connectors/mux/mux.go +++ b/quesma/v2/core/mux/mux.go @@ -7,9 +7,6 @@ import ( "github.com/ucarion/urlpath" "net/http" "net/url" - "quesma/frontend_connectors" - "quesma/logger" - "quesma/quesma/types" "strings" ) @@ -38,14 +35,14 @@ type ( QueryParams url.Values Body string - ParsedBody types.RequestBody + ParsedBody RequestBody } Handler func(ctx context.Context, req *Request) (*Result, error) MatchResult struct { Matched bool - Decision *frontend_connectors.Decision + Decision *Decision } RequestMatcher interface { Matches(req *Request) MatchResult @@ -86,23 +83,18 @@ func (p *PathRouter) Register(pattern string, predicate RequestMatcher, handler } -func (p *PathRouter) Matches(req *Request) (Handler, *frontend_connectors.Decision) { - if strings.Contains(req.Path, "fligh") { - logger.Debug().Msgf("Matched path: %s", req.Path) - } +func (p *PathRouter) Matches(req *Request) (Handler, *Decision) { handler, decision := p.findHandler(req) if handler != nil { routerStatistics.addMatched(req.Path) - logger.Debug().Msgf("Matched path: %s", req.Path) return handler, decision } else { routerStatistics.addUnmatched(req.Path) - logger.Debug().Msgf("Non-matched path: %s", req.Path) return handler, decision } } -func (p *PathRouter) findHandler(req *Request) (Handler, *frontend_connectors.Decision) { +func (p *PathRouter) findHandler(req *Request) (Handler, *Decision) { path := strings.TrimSuffix(req.Path, "/") for _, m := range p.mappings { meta, match := m.compiledPath.Match(path) @@ -142,7 +134,7 @@ type predicateAnd struct { } func (p *predicateAnd) Matches(req *Request) MatchResult { - var lastDecision *frontend_connectors.Decision + var lastDecision *Decision for _, predicate := range p.predicates { res := predicate.Matches(req) diff --git a/quesma/frontend_connectors/mux/mux_test.go b/quesma/v2/core/mux/mux_test.go similarity index 100% rename from quesma/frontend_connectors/mux/mux_test.go rename to quesma/v2/core/mux/mux_test.go diff --git a/quesma/v2/core/mux/request_body.go b/quesma/v2/core/mux/request_body.go new file mode 100644 index 000000000..066df1e0c --- /dev/null +++ b/quesma/v2/core/mux/request_body.go @@ -0,0 +1,7 @@ +// Copyright Quesma, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 +package mux + +type RequestBody interface { + IsParsedRequestBody() // this is a marker method +} diff --git a/quesma/frontend_connectors/routes/paths.go b/quesma/v2/core/routes/paths.go similarity index 100% rename from quesma/frontend_connectors/routes/paths.go rename to quesma/v2/core/routes/paths.go diff --git a/quesma/v2/go.mod b/quesma/v2/go.mod index 6a1e6e3cb..57e718812 100644 --- a/quesma/v2/go.mod +++ b/quesma/v2/go.mod @@ -3,27 +3,15 @@ module quesma_v2 go 1.23.2 require ( - github.com/go-sql-driver/mysql v1.8.1 - github.com/google/go-cmp v0.6.0 - github.com/google/uuid v1.6.0 - github.com/jackc/pgx/v4 v4.18.3 - github.com/jackc/pgx/v5 v5.7.1 github.com/stretchr/testify v1.10.0 + github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb ) require ( - filippo.io/edwards25519 v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.14.3 // indirect - github.com/jackc/pgio v1.0.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.3 // indirect - github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgtype v1.14.0 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.13.1 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/text v0.18.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/quesma/v2/go.sum b/quesma/v2/go.sum index 59f0a59dc..88ad610aa 100644 --- a/quesma/v2/go.sum +++ b/quesma/v2/go.sum @@ -1,196 +1,27 @@ -filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= -filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= -github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= -github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= -github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= -github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= -github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= -github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= -github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= -github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= -github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= -github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= -github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= -github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= -github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= -github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= -github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= -github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= -github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= -github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= -github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= -github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= -github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= -github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= -github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA= -github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= -github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs= -github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA= -github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb h1:Ywfo8sUltxogBpFuMOFRrrSifO788kAFxmvVw31PtQQ= +github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb/go.mod h1:ikPs9bRWicNw3S7XpJ8sK/smGwU9WcSVU3dy9qahYBM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=