From ff4da059cd2def04a50c0721cd8eec4703d13bd3 Mon Sep 17 00:00:00 2001 From: Przemek Delewski Date: Thu, 16 Jan 2025 15:30:58 +0100 Subject: [PATCH] Adding comments --- quesma/processors/base_processor.go | 2 +- quesma/quesma/v2_test.go | 2 +- quesma/v2/core/quesma_apis.go | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/quesma/processors/base_processor.go b/quesma/processors/base_processor.go index fb2d23490..08cfdfef6 100644 --- a/quesma/processors/base_processor.go +++ b/quesma/processors/base_processor.go @@ -80,6 +80,6 @@ func (p *BaseProcessor) Handle(metadata map[string]interface{}, messages ...any) return metadata, resp, nil } -func (p *BaseProcessor) RegisterTransfomationPipeline(pipeline quesma_api.QueryTransformationPipeline) { +func (p *BaseProcessor) RegisterTransformationPipeline(pipeline quesma_api.QueryTransformationPipeline) { p.QueryTransformationPipeline = pipeline } diff --git a/quesma/quesma/v2_test.go b/quesma/quesma/v2_test.go index b7c907e55..412884e56 100644 --- a/quesma/quesma/v2_test.go +++ b/quesma/quesma/v2_test.go @@ -139,7 +139,7 @@ func full_workflow_scenario() quesma_api.QuesmaBuilder { queryTransformationPipe := NewQueryTransformationPipeline() queryTransformationPipe.AddTransformer(NewQueryTransformer1()) - queryProcessor.RegisterTransfomationPipeline(queryTransformationPipe) + queryProcessor.RegisterTransformationPipeline(queryTransformationPipe) queryPipeline.AddProcessor(queryProcessor) quesmaBuilder.AddPipeline(queryPipeline) diff --git a/quesma/v2/core/quesma_apis.go b/quesma/v2/core/quesma_apis.go index 0edc1f4e1..d96fbce4c 100644 --- a/quesma/v2/core/quesma_apis.go +++ b/quesma/v2/core/quesma_apis.go @@ -75,22 +75,37 @@ type QuesmaBuilder interface { Stop(ctx context.Context) } +// Query This is placeholder +// Concrete definition will be taken +// from `quesma/model/query.go` type Query struct { Query string } +// ExecutionPlan This is placeholder +// Concrete definition will be taken +// from `quesma/model/query.go` type ExecutionPlan struct { Queries []*Query } +// QueryResultTransformer This is a copy of the +// interface `ResultTransformer` from `quesma/model/transformers.go` +// from `quesma/model/transformers.go` type QueryResultTransformer interface { TransformResults(results [][]QueryResultRow) [][]QueryResultRow } +// QueryTransformer This is a copy of the +// interface `QueryTransformer` from `quesma/model/transformers.go` +// from `quesma/model/transformers.go` type QueryTransformer interface { Transform(query []*Query) ([]*Query, error) } +// QueryTransformationPipeline is the interface that parsing and composing +// `QueryTransformer` and `QueryResultTransformer` +// and makes body of BaseProcessor::Handle() method type QueryTransformationPipeline interface { QueryTransformer QueryResultTransformer @@ -100,9 +115,13 @@ type QueryTransformationPipeline interface { GetTransformers() []QueryTransformer } +// QueryResultRow This is a copy of the +// struct `QueryResultRow` from `quesma/model/query.go` +// and something that we should unify type QueryResultRow struct { } +// QueryExecutor is the interface that wraps the ExecuteQuery method. type QueryExecutor interface { ExecuteQuery(query string) ([]QueryResultRow, error) } @@ -115,7 +134,9 @@ type Processor interface { SetBackendConnectors(conns map[BackendConnectorType]BackendConnector) GetBackendConnector(connectorType BackendConnectorType) BackendConnector GetSupportedBackendConnectors() []BackendConnectorType - RegisterTransfomationPipeline(pipeline QueryTransformationPipeline) + // RegisterTransformationPipeline method can be part of BaseProcessor + // not interface itself + RegisterTransformationPipeline(pipeline QueryTransformationPipeline) Init() error }