creatorupdatordeprecate
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
# https://taskfile.dev
|
|
||||||
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
includes:
|
|
||||||
lib:
|
|
||||||
taskfile: scripts/Taskfile.yml
|
|
||||||
flatten: true
|
|
||||||
vars:
|
|
||||||
IMAGE_NAME: queryorchestration
|
|
||||||
COVERAGE_THRESHOLD: 80
|
|
||||||
@@ -3,6 +3,7 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||||
"queryorchestration/internal/query"
|
"queryorchestration/internal/query"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseQuery(query *query.Query) *serviceinterfaces.Query {
|
func ParseQuery(query *query.Query) *serviceinterfaces.Query {
|
||||||
@@ -19,24 +20,24 @@ func ParseQuery(query *query.Query) *serviceinterfaces.Query {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseQueryType(qType query.Type) serviceinterfaces.QueryType {
|
func ParseQueryType(qType queryprocessor.Type) serviceinterfaces.QueryType {
|
||||||
switch qType {
|
switch qType {
|
||||||
case query.TypeJsonExtractor:
|
case queryprocessor.TypeJsonExtractor:
|
||||||
return serviceinterfaces.QueryType_QUERY_TYPE_JSON_EXTRACTOR
|
return serviceinterfaces.QueryType_QUERY_TYPE_JSON_EXTRACTOR
|
||||||
case query.TypeContextFull:
|
case queryprocessor.TypeContextFull:
|
||||||
return serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL
|
return serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL
|
||||||
default:
|
default:
|
||||||
return serviceinterfaces.QueryType_QUERY_TYPE_UNSPECIFIED
|
return serviceinterfaces.QueryType_QUERY_TYPE_UNSPECIFIED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseSpecQueryType(qType serviceinterfaces.QueryType) query.Type {
|
func ParseSpecQueryType(qType serviceinterfaces.QueryType) queryprocessor.Type {
|
||||||
switch qType {
|
switch qType {
|
||||||
case serviceinterfaces.QueryType_QUERY_TYPE_JSON_EXTRACTOR:
|
case serviceinterfaces.QueryType_QUERY_TYPE_JSON_EXTRACTOR:
|
||||||
return query.TypeJsonExtractor
|
return queryprocessor.TypeJsonExtractor
|
||||||
case serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL:
|
case serviceinterfaces.QueryType_QUERY_TYPE_CONTEXT_FULL:
|
||||||
return query.TypeContextFull
|
return queryprocessor.TypeContextFull
|
||||||
default:
|
default:
|
||||||
return query.TypeContextFull
|
return queryprocessor.TypeContextFull
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"queryorchestration/api/grpc/spec"
|
||||||
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
serviceinterfaces "queryorchestration/api/serviceInterfaces"
|
||||||
"queryorchestration/internal/query"
|
"queryorchestration/internal/query"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -25,9 +27,9 @@ func NewQueryController(querySvc query.Service, validator *validator.Validate) *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *QueryController) List(ctx context.Context, req *serviceinterfaces.QueryFilter) (*serviceinterfaces.Queries, error) {
|
func (s *QueryController) List(ctx context.Context, req *serviceinterfaces.QueryFilter) (*serviceinterfaces.Queries, error) {
|
||||||
types := make([]query.Type, len(req.GetTypes()))
|
types := make([]queryprocessor.Type, len(req.GetTypes()))
|
||||||
for index, t := range req.GetTypes() {
|
for index, t := range req.GetTypes() {
|
||||||
types[index] = query.Type(ParseSpecQueryType(t))
|
types[index] = queryprocessor.Type(ParseSpecQueryType(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
filters := query.ListFilters{
|
filters := query.ListFilters{
|
||||||
@@ -74,7 +76,7 @@ func (s *QueryController) Create(ctx context.Context, req *serviceinterfaces.Que
|
|||||||
requiredQueryIDs[index] = parsedID
|
requiredQueryIDs[index] = parsedID
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := s.query.Create(ctx, query.Create{
|
id, err := s.query.Create(ctx, &queryprocessor.Create{
|
||||||
Type: ParseSpecQueryType(req.GetType()),
|
Type: ParseSpecQueryType(req.GetType()),
|
||||||
RequiredQueryIDs: requiredQueryIDs,
|
RequiredQueryIDs: requiredQueryIDs,
|
||||||
})
|
})
|
||||||
@@ -93,7 +95,7 @@ func (s *QueryController) Update(ctx context.Context, req *serviceinterfaces.Que
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.query.Update(ctx, query.Update{
|
err = s.query.Update(ctx, &queryprocessor.Update{
|
||||||
ID: id,
|
ID: id,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -103,13 +105,13 @@ func (s *QueryController) Update(ctx context.Context, req *serviceinterfaces.Que
|
|||||||
return &emptypb.Empty{}, nil
|
return &emptypb.Empty{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *QueryController) Remove(ctx context.Context, req *serviceinterfaces.IdMessage) (*emptypb.Empty, error) {
|
func (s *QueryController) Deprecate(ctx context.Context, req *spec.IdMessage) (*emptypb.Empty, error) {
|
||||||
id, err := uuid.Parse(req.GetId())
|
id, err := uuid.Parse(req.GetId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.query.Remove(ctx, id)
|
err = s.query.Deprecate(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule api/serviceInterfaces updated: c41bce6522...e3d7e63a27
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE queryDeprecations;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE queryDeprecations (
|
||||||
|
id uuid primary key DEFAULT gen_random_uuid(),
|
||||||
|
queryId uuid not null,
|
||||||
|
time timestamp not null DEFAULT NOW(),
|
||||||
|
removedAt timestamp,
|
||||||
|
foreign key (queryId) references queries(id),
|
||||||
|
unique (queryId, removedAt)
|
||||||
|
);
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
-- name: GetCollectorQueries :many
|
-- name: GetCollectorQueries :many
|
||||||
SELECT collectorId, queryId, type, requiredQueryId, queryVersion FROM collectorQueryDependencyTree WHERE collectorId = $1;
|
SELECT collectorId, queryId, type, queryVersion, ARRAY_AGG(requiredQueryId) AS requiredIds
|
||||||
|
FROM collectorQueryDependencyTree
|
||||||
|
WHERE collectorId = $1
|
||||||
|
GROUP BY queryId, collectorId, type, queryVersion;
|
||||||
|
|
||||||
-- name: GetCollectorFromJobID :one
|
-- name: GetCollectorFromJobID :one
|
||||||
SELECT id, jobId, minCleanVersion, minTextVersion FROM collectors WHERE jobId = $1 LIMIT 1;
|
SELECT id, jobId, minCleanVersion, minTextVersion FROM collectors WHERE jobId = $1 LIMIT 1;
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
-- name: GetQueryConfig :one
|
-- name: GetQueryConfig :one
|
||||||
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2;
|
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2;
|
||||||
|
|
||||||
|
-- name: GetQueryType :one
|
||||||
|
SELECT type FROM queries where id = $1;
|
||||||
|
|
||||||
|
-- name: DeprecateQuery :exec
|
||||||
|
INSERT INTO queryDeprecations (queryId) VALUES ($1) RETURNING id;
|
||||||
|
|
||||||
|
-- name: IsQueryDeprecated :one
|
||||||
|
SELECT EXISTS (
|
||||||
|
SELECT 1 FROM queryDeprecations where queryId = $1 and removedAt is not null
|
||||||
|
);
|
||||||
|
|
||||||
-- name: GetQuery :one
|
-- name: GetQuery :one
|
||||||
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
|
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
|
||||||
FROM queries AS q
|
FROM queries AS q
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package contextfull
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/database/repository"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Creator struct {
|
||||||
|
db *repository.Queries
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreator(db *repository.Queries) Creator {
|
||||||
|
return Creator{db}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Creator) Validate(ctx context.Context, entity *queryprocessor.Create) error {
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Creator) Create(ctx context.Context, entity *queryprocessor.Create) (uuid.UUID, error) {
|
||||||
|
err := s.Validate(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return uuid.Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return uuid.Nil, nil
|
||||||
|
}
|
||||||
@@ -3,21 +3,22 @@ package contextfull
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Extractor struct {
|
type Extractor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Extractor {
|
func NewExtractor() Extractor {
|
||||||
return &Extractor{}
|
return Extractor{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Extractor) Process(ctx context.Context, query query.QueryRow, values *[]result.Value) (string, error) {
|
func (e Extractor) Process(ctx context.Context, query queryprocessor.Query, values *[]result.Value) (string, error) {
|
||||||
if len(*values) > 0 {
|
if len(*values) > 0 {
|
||||||
return "", fmt.Errorf("no requirements expected")
|
return "", fmt.Errorf("no requirements expected")
|
||||||
}
|
}
|
||||||
|
// TODO
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package contextfull
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/database/repository"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Updator struct {
|
||||||
|
db *repository.Queries
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUpdator(db *repository.Queries) Updator {
|
||||||
|
return Updator{db}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Updator) Validate(ctx context.Context, entity *queryprocessor.Update) error {
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Updator) Update(ctx context.Context, entity *queryprocessor.Update) error {
|
||||||
|
err := s.Validate(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -35,15 +35,18 @@ func (q *Queries) GetCollectorFromJobID(ctx context.Context, jobid pgtype.UUID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCollectorQueries = `-- name: GetCollectorQueries :many
|
const getCollectorQueries = `-- name: GetCollectorQueries :many
|
||||||
SELECT collectorId, queryId, type, requiredQueryId, queryVersion FROM collectorQueryDependencyTree WHERE collectorId = $1
|
SELECT collectorId, queryId, type, queryVersion, ARRAY_AGG(requiredQueryId) AS requiredIds
|
||||||
|
FROM collectorQueryDependencyTree
|
||||||
|
WHERE collectorId = $1
|
||||||
|
GROUP BY queryId, collectorId, type, queryVersion
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetCollectorQueriesRow struct {
|
type GetCollectorQueriesRow struct {
|
||||||
Collectorid pgtype.UUID
|
Collectorid pgtype.UUID
|
||||||
Queryid pgtype.UUID
|
Queryid pgtype.UUID
|
||||||
Type NullQuerytype
|
Type NullQuerytype
|
||||||
Requiredqueryid pgtype.UUID
|
Queryversion pgtype.Int4
|
||||||
Queryversion pgtype.Int4
|
Requiredids []pgtype.UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetCollectorQueries(ctx context.Context, collectorid pgtype.UUID) ([]GetCollectorQueriesRow, error) {
|
func (q *Queries) GetCollectorQueries(ctx context.Context, collectorid pgtype.UUID) ([]GetCollectorQueriesRow, error) {
|
||||||
@@ -59,8 +62,8 @@ func (q *Queries) GetCollectorQueries(ctx context.Context, collectorid pgtype.UU
|
|||||||
&i.Collectorid,
|
&i.Collectorid,
|
||||||
&i.Queryid,
|
&i.Queryid,
|
||||||
&i.Type,
|
&i.Type,
|
||||||
&i.Requiredqueryid,
|
|
||||||
&i.Queryversion,
|
&i.Queryversion,
|
||||||
|
&i.Requiredids,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,13 @@ type Queryconfig struct {
|
|||||||
Removedversion pgtype.Int4
|
Removedversion pgtype.Int4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Querydeprecation struct {
|
||||||
|
ID pgtype.UUID
|
||||||
|
Queryid pgtype.UUID
|
||||||
|
Time pgtype.Timestamp
|
||||||
|
Removedat pgtype.Timestamp
|
||||||
|
}
|
||||||
|
|
||||||
type Requiredquery struct {
|
type Requiredquery struct {
|
||||||
ID pgtype.UUID
|
ID pgtype.UUID
|
||||||
Queryid pgtype.UUID
|
Queryid pgtype.UUID
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ import (
|
|||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deprecateQuery = `-- name: DeprecateQuery :exec
|
||||||
|
INSERT INTO queryDeprecations (queryId) VALUES ($1) RETURNING id
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) DeprecateQuery(ctx context.Context, queryid pgtype.UUID) error {
|
||||||
|
_, err := q.db.Exec(ctx, deprecateQuery, queryid)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
const getQuery = `-- name: GetQuery :one
|
const getQuery = `-- name: GetQuery :one
|
||||||
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
|
SELECT q.id, q.type, q.activeVersion, c.config, ARRAY_AGG(r.requiredQueryId) AS requiredIds
|
||||||
FROM queries AS q
|
FROM queries AS q
|
||||||
@@ -65,3 +74,27 @@ func (q *Queries) GetQueryConfig(ctx context.Context, arg GetQueryConfigParams)
|
|||||||
err := row.Scan(&i.ID, &i.Config)
|
err := row.Scan(&i.ID, &i.Config)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getQueryType = `-- name: GetQueryType :one
|
||||||
|
SELECT type FROM queries where id = $1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetQueryType(ctx context.Context, id pgtype.UUID) (Querytype, error) {
|
||||||
|
row := q.db.QueryRow(ctx, getQueryType, id)
|
||||||
|
var type_ Querytype
|
||||||
|
err := row.Scan(&type_)
|
||||||
|
return type_, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const isQueryDeprecated = `-- name: IsQueryDeprecated :one
|
||||||
|
SELECT EXISTS (
|
||||||
|
SELECT 1 FROM queryDeprecations where queryId = $1 and removedAt is not null
|
||||||
|
)
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) IsQueryDeprecated(ctx context.Context, queryid pgtype.UUID) (bool, error) {
|
||||||
|
row := q.db.QueryRow(ctx, isQueryDeprecated, queryid)
|
||||||
|
var exists bool
|
||||||
|
err := row.Scan(&exists)
|
||||||
|
return exists, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package jsonextractor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/database/repository"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Creator struct {
|
||||||
|
db *repository.Queries
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreator(db *repository.Queries) Creator {
|
||||||
|
return Creator{db}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Creator) Validate(ctx context.Context, entity *queryprocessor.Create) error {
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Creator) Create(ctx context.Context, entity *queryprocessor.Create) (uuid.UUID, error) {
|
||||||
|
err := s.Validate(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return uuid.Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return uuid.Nil, nil
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@@ -20,11 +20,11 @@ type Config struct {
|
|||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(db *repository.Queries) *Extractor {
|
func NewExtractor(db *repository.Queries) Extractor {
|
||||||
return &Extractor{db}
|
return Extractor{db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Extractor) Process(ctx context.Context, query query.QueryRow, values *[]result.Value) (string, error) {
|
func (e Extractor) Process(ctx context.Context, query queryprocessor.Query, values *[]result.Value) (string, error) {
|
||||||
if len(*values) != 1 {
|
if len(*values) != 1 {
|
||||||
return "", fmt.Errorf("JSON Extraction requires 1 result")
|
return "", fmt.Errorf("JSON Extraction requires 1 result")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package jsonextractor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/database/repository"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Updator struct {
|
||||||
|
db *repository.Queries
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUpdator(db *repository.Queries) Updator {
|
||||||
|
return Updator{db}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Updator) Validate(ctx context.Context, entity *queryprocessor.Update) error {
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Updator) Update(ctx context.Context, entity *queryprocessor.Update) error {
|
||||||
|
err := s.Validate(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
contextfull "queryorchestration/internal/contextFull"
|
||||||
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Service) Create(ctx context.Context, entity *queryprocessor.Create) (uuid.UUID, error) {
|
||||||
|
validator, err := s.getCreator(entity.Type)
|
||||||
|
if err != nil {
|
||||||
|
return uuid.Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
id, err := validator.Create(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return uuid.Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return id, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) getCreator(qType queryprocessor.Type) (queryprocessor.Creator, error) {
|
||||||
|
switch qType {
|
||||||
|
case queryprocessor.TypeJsonExtractor:
|
||||||
|
return jsonextractor.NewCreator(s.db), nil
|
||||||
|
case queryprocessor.TypeContextFull:
|
||||||
|
return contextfull.NewCreator(s.db), nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("attempting to process invalid query type")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/database"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Service) Deprecate(ctx context.Context, id uuid.UUID) error {
|
||||||
|
dbId := database.MustToDBUUID(id)
|
||||||
|
|
||||||
|
exists, err := s.db.IsQueryDeprecated(ctx, dbId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if exists {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.db.DeprecateQuery(ctx, dbId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Service) List(ctx context.Context, filters ListFilters) (*[]Query, error) {
|
||||||
|
// TODO
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
@@ -4,54 +4,27 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/result"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Type int
|
|
||||||
|
|
||||||
const (
|
|
||||||
TypeJsonExtractor = iota
|
|
||||||
TypeContextFull
|
|
||||||
)
|
|
||||||
|
|
||||||
type QueryRow struct {
|
|
||||||
ID uuid.UUID
|
|
||||||
Type Type
|
|
||||||
RequiredQueryID uuid.UUID
|
|
||||||
Version int32
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query struct {
|
type Query struct {
|
||||||
ID uuid.UUID
|
ID uuid.UUID
|
||||||
Type Type
|
Type queryprocessor.Type
|
||||||
RequiredQueryIDs []uuid.UUID
|
RequiredQueryIDs []uuid.UUID
|
||||||
Version int32
|
Version int32
|
||||||
Config interface{}
|
Config interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListFilters struct {
|
type ListFilters struct {
|
||||||
Types []Type
|
Types []queryprocessor.Type
|
||||||
}
|
|
||||||
|
|
||||||
type Create struct {
|
|
||||||
Type Type
|
|
||||||
RequiredQueryIDs []uuid.UUID
|
|
||||||
}
|
|
||||||
|
|
||||||
type Update struct {
|
|
||||||
ID uuid.UUID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Test struct {
|
type Test struct {
|
||||||
ID uuid.UUID
|
ID uuid.UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
type Processor interface {
|
|
||||||
Process(ctx context.Context, query QueryRow, values *[]result.Value) (string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
db *repository.Queries
|
db *repository.Queries
|
||||||
}
|
}
|
||||||
@@ -66,7 +39,7 @@ func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Query, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
queryType, err := ParseDBType(query.Type)
|
queryType, err := queryprocessor.ParseDBType(query.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -84,26 +57,3 @@ func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Query, error) {
|
|||||||
Config: string(query.Config),
|
Config: string(query.Config),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) List(ctx context.Context, filters ListFilters) (*[]Query, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, entity Create) (uuid.UUID, error) {
|
|
||||||
return uuid.Nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Update(ctx context.Context, entity Update) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Remove(ctx context.Context, id uuid.UUID) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Test(ctx context.Context, filters Test) (string, error) {
|
|
||||||
// Sync doc
|
|
||||||
// Run test
|
|
||||||
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Service) Test(ctx context.Context, filters Test) (string, error) {
|
||||||
|
// TODO
|
||||||
|
// Sync doc
|
||||||
|
// Run test
|
||||||
|
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
contextfull "queryorchestration/internal/contextFull"
|
||||||
|
"queryorchestration/internal/database"
|
||||||
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Service) Update(ctx context.Context, entity *queryprocessor.Update) error {
|
||||||
|
dbType, err := s.db.GetQueryType(ctx, database.MustToDBUUID(entity.ID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
qType, err := queryprocessor.ParseDBType(dbType)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
validator, err := s.getUpdator(qType)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validator.Update(ctx, entity)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) getUpdator(qType queryprocessor.Type) (queryprocessor.Updator, error) {
|
||||||
|
switch qType {
|
||||||
|
case queryprocessor.TypeJsonExtractor:
|
||||||
|
return jsonextractor.NewUpdator(s.db), nil
|
||||||
|
case queryprocessor.TypeContextFull:
|
||||||
|
return contextfull.NewUpdator(s.db), nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("attempting to process invalid query type")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +1,13 @@
|
|||||||
package query
|
package queryprocessor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseDBQueryRow(dbQuery *repository.GetCollectorQueriesRow) (*QueryRow, error) {
|
|
||||||
t, err := ParseDBNullType(dbQuery.Type)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &QueryRow{
|
|
||||||
ID: database.MustToUUID(dbQuery.Queryid),
|
|
||||||
Type: t,
|
|
||||||
RequiredQueryID: database.MustToUUID(dbQuery.Requiredqueryid),
|
|
||||||
Version: dbQuery.Queryversion.Int32,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseDBNullType(qType repository.NullQuerytype) (Type, error) {
|
func ParseDBNullType(qType repository.NullQuerytype) (Type, error) {
|
||||||
if !qType.Valid {
|
if !qType.Valid {
|
||||||
return TypeJsonExtractor, fmt.Errorf("invalid database query type")
|
return TypeJsonExtractor, fmt.Errorf("invalid database query type")
|
||||||
@@ -53,3 +41,22 @@ func ToDBQueryType(t Type) (repository.NullQuerytype, error) {
|
|||||||
|
|
||||||
return repository.NullQuerytype{Querytype: dbType, Valid: true}, nil
|
return repository.NullQuerytype{Querytype: dbType, Valid: true}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ParseDBQuery(q *repository.GetCollectorQueriesRow) (*Query, error) {
|
||||||
|
reqQueryIDs := make([]uuid.UUID, len(q.Requiredids))
|
||||||
|
for index, id := range q.Requiredids {
|
||||||
|
reqQueryIDs[index] = database.MustToUUID(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
qType, err := ParseDBNullType(q.Type)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Query{
|
||||||
|
ID: database.MustToUUID(q.Queryid),
|
||||||
|
Version: q.Queryversion.Int32,
|
||||||
|
Type: qType,
|
||||||
|
RequiredQueryIDs: reqQueryIDs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package queryprocessor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"queryorchestration/internal/result"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Type int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TypeJsonExtractor = iota
|
||||||
|
TypeContextFull
|
||||||
|
)
|
||||||
|
|
||||||
|
type Create struct {
|
||||||
|
Type Type
|
||||||
|
RequiredQueryIDs []uuid.UUID
|
||||||
|
Config interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Update struct {
|
||||||
|
ID uuid.UUID
|
||||||
|
RequiredQueryIDs []uuid.UUID
|
||||||
|
Config interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query struct {
|
||||||
|
ID uuid.UUID
|
||||||
|
Type Type
|
||||||
|
Version int32
|
||||||
|
RequiredQueryIDs []uuid.UUID
|
||||||
|
Config interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Creator interface {
|
||||||
|
Validate(ctx context.Context, entity *Create) error
|
||||||
|
Create(ctx context.Context, entity *Create) (uuid.UUID, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Updator interface {
|
||||||
|
Validate(ctx context.Context, entity *Update) error
|
||||||
|
Update(ctx context.Context, entity *Update) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Processor interface {
|
||||||
|
Process(ctx context.Context, query Query, values *[]result.Value) (string, error)
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package queryQueue
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (q *Queue) getUnsyncedQueries() {
|
func (q *Queue) getUnsyncedQueries() {
|
||||||
@@ -36,9 +36,9 @@ func (c *Queue) getCollectorQueries(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanQueries := make([]query.QueryRow, len(queries))
|
cleanQueries := make([]queryprocessor.Query, len(queries))
|
||||||
for index, dbQuery := range queries {
|
for index, dbQuery := range queries {
|
||||||
cleanQuery, err := query.ParseDBQueryRow(&dbQuery)
|
cleanQuery, err := queryprocessor.ParseDBQuery(&dbQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -51,33 +51,39 @@ func (c *Queue) getCollectorQueries(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queue) Add(qu *query.QueryRow) {
|
func (q *Queue) Add(qu *queryprocessor.Query) {
|
||||||
dependentQueries := []query.QueryRow{}
|
dependentQueries := []queryprocessor.Query{}
|
||||||
requiredIndex := -1
|
requiredIndex := -1
|
||||||
|
|
||||||
if q.unsyncedQueue == nil {
|
if q.unsyncedQueue == nil {
|
||||||
q.unsyncedQueue = &[]query.QueryRow{}
|
q.unsyncedQueue = &[]queryprocessor.Query{}
|
||||||
} else {
|
} else {
|
||||||
for index, entry := range *q.unsyncedQueue {
|
for index, entry := range *q.unsyncedQueue {
|
||||||
if entry.ID == qu.ID {
|
if entry.ID == qu.ID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entry.ID == qu.RequiredQueryID {
|
for _, id := range qu.RequiredQueryIDs {
|
||||||
requiredIndex = index
|
if entry.ID == id {
|
||||||
|
requiredIndex = index
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range *q.collectorQueries {
|
for _, entry := range *q.collectorQueries {
|
||||||
if entry.RequiredQueryID == qu.ID {
|
for _, id := range entry.RequiredQueryIDs {
|
||||||
dependentQueries = append(dependentQueries, entry)
|
if qu.ID == id {
|
||||||
|
dependentQueries = append(dependentQueries, entry)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if requiredIndex != -1 {
|
if requiredIndex != -1 {
|
||||||
*q.unsyncedQueue = append((*q.unsyncedQueue)[:requiredIndex+1], append([]query.QueryRow{*qu}, (*q.unsyncedQueue)[requiredIndex+1:]...)...)
|
*q.unsyncedQueue = append((*q.unsyncedQueue)[:requiredIndex+1], append([]queryprocessor.Query{*qu}, (*q.unsyncedQueue)[requiredIndex+1:]...)...)
|
||||||
} else {
|
} else {
|
||||||
*q.unsyncedQueue = append([]query.QueryRow{*qu}, *q.unsyncedQueue...)
|
*q.unsyncedQueue = append([]queryprocessor.Query{*qu}, *q.unsyncedQueue...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range dependentQueries {
|
for _, entry := range dependentQueries {
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import (
|
|||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
jsonextractor "queryorchestration/internal/jsonExtractor"
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,16 +30,9 @@ func (q *Queue) Execute(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queue) executeQuery(ctx context.Context, qu query.QueryRow) error {
|
func (q *Queue) executeQuery(ctx context.Context, qu queryprocessor.Query) error {
|
||||||
requiredQueryIDs := []uuid.UUID{}
|
resultIDs := make([]pgtype.UUID, len(qu.RequiredQueryIDs))
|
||||||
for _, entry := range *q.collectorQueries {
|
for index, id := range qu.RequiredQueryIDs {
|
||||||
if entry.ID == qu.ID && entry.RequiredQueryID != uuid.Nil {
|
|
||||||
requiredQueryIDs = append(requiredQueryIDs, entry.RequiredQueryID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resultIDs := make([]pgtype.UUID, len(requiredQueryIDs))
|
|
||||||
for index, id := range requiredQueryIDs {
|
|
||||||
var queryVersion int32
|
var queryVersion int32
|
||||||
for _, entry := range *q.collectorQueries {
|
for _, entry := range *q.collectorQueries {
|
||||||
if entry.ID == id {
|
if entry.ID == id {
|
||||||
@@ -81,7 +73,7 @@ func (q *Queue) executeQuery(ctx context.Context, qu query.QueryRow) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queue) getResultValue(res *repository.ListResultValuesByIDRow) (result.Value, error) {
|
func (q *Queue) getResultValue(res *repository.ListResultValuesByIDRow) (result.Value, error) {
|
||||||
var queryType query.Type
|
var queryType queryprocessor.Type
|
||||||
for _, qu := range *q.collectorQueries {
|
for _, qu := range *q.collectorQueries {
|
||||||
if qu.ID == database.MustToUUID(res.Queryid) {
|
if qu.ID == database.MustToUUID(res.Queryid) {
|
||||||
queryType = qu.Type
|
queryType = qu.Type
|
||||||
@@ -89,9 +81,9 @@ func (q *Queue) getResultValue(res *repository.ListResultValuesByIDRow) (result.
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch queryType {
|
switch queryType {
|
||||||
case query.TypeJsonExtractor:
|
case queryprocessor.TypeJsonExtractor:
|
||||||
return jsonextractor.NewResult(res.Value), nil
|
return jsonextractor.NewResult(res.Value), nil
|
||||||
case query.TypeContextFull:
|
case queryprocessor.TypeContextFull:
|
||||||
return contextfull.NewResult(res.Value), nil
|
return contextfull.NewResult(res.Value), nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("attempting to process invalid query type")
|
return nil, fmt.Errorf("attempting to process invalid query type")
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
contextfull "queryorchestration/internal/contextFull"
|
contextfull "queryorchestration/internal/contextFull"
|
||||||
jsonextractor "queryorchestration/internal/jsonExtractor"
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (q *Queue) setResult(ctx context.Context, qu query.QueryRow, resultValues *[]result.Value) error {
|
func (q *Queue) setResult(ctx context.Context, qu queryprocessor.Query, resultValues *[]result.Value) error {
|
||||||
processor, err := q.getProcessor(qu.Type)
|
processor, err := q.getProcessor(qu.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -41,12 +41,12 @@ func (q *Queue) setResult(ctx context.Context, qu query.QueryRow, resultValues *
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queue) getProcessor(queryType query.Type) (query.Processor, error) {
|
func (q *Queue) getProcessor(queryType queryprocessor.Type) (queryprocessor.Processor, error) {
|
||||||
switch queryType {
|
switch queryType {
|
||||||
case query.TypeJsonExtractor:
|
case queryprocessor.TypeJsonExtractor:
|
||||||
return jsonextractor.New(q.db), nil
|
return jsonextractor.NewExtractor(q.db), nil
|
||||||
case query.TypeContextFull:
|
case queryprocessor.TypeContextFull:
|
||||||
return contextfull.New(), nil
|
return contextfull.NewExtractor(), nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("attempting to process invalid query type")
|
return nil, fmt.Errorf("attempting to process invalid query type")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"queryorchestration/internal/collector"
|
"queryorchestration/internal/collector"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Queue struct {
|
type Queue struct {
|
||||||
unsyncedQueue *[]query.QueryRow
|
unsyncedQueue *[]queryprocessor.Query
|
||||||
collectorQueries *[]query.QueryRow
|
collectorQueries *[]queryprocessor.Query
|
||||||
results *[]result.Result
|
results *[]result.Result
|
||||||
collector *collector.Collector
|
collector *collector.Collector
|
||||||
db *repository.Queries
|
db *repository.Queries
|
||||||
@@ -41,6 +41,6 @@ func New(ctx context.Context, db *repository.Queries, coll *collector.Collector,
|
|||||||
return &queue, nil
|
return &queue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queue) GetQueue() []query.QueryRow {
|
func (q *Queue) GetQueue() []queryprocessor.Query {
|
||||||
return *q.unsyncedQueue
|
return *q.unsyncedQueue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,4 @@ tasks:
|
|||||||
- protolint lint -fix {{.PROTO_DIR}}
|
- protolint lint -fix {{.PROTO_DIR}}
|
||||||
generate:
|
generate:
|
||||||
cmds:
|
cmds:
|
||||||
- pwd
|
|
||||||
- mkdir -p {{.API_DIR}}/serviceInterfaces
|
|
||||||
- protoc --proto_path={{.PROTO_DIR}} --go_out={{.API_DIR}}/serviceInterfaces --go-grpc_out={{.API_DIR}} --go_opt=paths=source_relative --experimental_allow_proto3_optional main.proto
|
- protoc --proto_path={{.PROTO_DIR}} --go_out={{.API_DIR}}/serviceInterfaces --go-grpc_out={{.API_DIR}} --go_opt=paths=source_relative --experimental_allow_proto3_optional main.proto
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package document_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
contextfull "queryorchestration/internal/contextFull"
|
contextfull "queryorchestration/internal/contextFull"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -14,13 +14,13 @@ import (
|
|||||||
func TestContextFull(t *testing.T) {
|
func TestContextFull(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
extractor := contextfull.New()
|
extractor := contextfull.NewExtractor()
|
||||||
|
|
||||||
query := query.QueryRow{
|
query := queryprocessor.Query{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Type: query.TypeJsonExtractor,
|
Type: queryprocessor.TypeJsonExtractor,
|
||||||
RequiredQueryID: uuid.Nil,
|
RequiredQueryIDs: []uuid.UUID{},
|
||||||
Version: int32(1),
|
Version: int32(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
values := &[]result.Value{}
|
values := &[]result.Value{}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ func TestSyncIsSynced(t *testing.T) {
|
|||||||
)
|
)
|
||||||
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
||||||
WillReturnRows(
|
WillReturnRows(
|
||||||
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "requiredQueryId", "queryVersion"}).
|
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "queryVersion", "requiredIds"}).
|
||||||
AddRow(dbCollectorId, pgtype.UUID{}, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.UUID{}, pgtype.Int4{Int32: int32(1), Valid: true}),
|
AddRow(dbCollectorId, pgtype.UUID{}, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.Int4{Int32: int32(1), Valid: true}, []pgtype.UUID{}),
|
||||||
)
|
)
|
||||||
|
|
||||||
docSvc := document.New(queries)
|
docSvc := document.New(queries)
|
||||||
@@ -131,8 +131,8 @@ func TestSyncDBFail(t *testing.T) {
|
|||||||
errr = "database failure"
|
errr = "database failure"
|
||||||
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
||||||
WillReturnRows(
|
WillReturnRows(
|
||||||
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "requiredQueryId", "queryVersion"}).
|
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "queryVersion", "requiredIds"}).
|
||||||
AddRow(dbCollectorId, dbQueryID, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.UUID{}, pgtype.Int4{Int32: int32(1), Valid: true}),
|
AddRow(dbCollectorId, dbQueryID, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.Int4{Int32: int32(1), Valid: true}, []pgtype.UUID{}),
|
||||||
)
|
)
|
||||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs([]pgtype.UUID{}).
|
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs([]pgtype.UUID{}).
|
||||||
WillReturnError(errors.New(errr))
|
WillReturnError(errors.New(errr))
|
||||||
@@ -176,8 +176,8 @@ func TestSync(t *testing.T) {
|
|||||||
)
|
)
|
||||||
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorId).
|
||||||
WillReturnRows(
|
WillReturnRows(
|
||||||
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "requiredQueryId", "queryVersion"}).
|
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "queryVersion", "requiredIds"}).
|
||||||
AddRow(dbCollectorId, dbQueryID, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.UUID{}, pgtype.Int4{Int32: int32(1), Valid: true}),
|
AddRow(dbCollectorId, dbQueryID, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, pgtype.Int4{Int32: int32(1), Valid: true}, []pgtype.UUID{}),
|
||||||
)
|
)
|
||||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs([]pgtype.UUID{}).
|
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs([]pgtype.UUID{}).
|
||||||
WillReturnRows(
|
WillReturnRows(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
jsonextractor "queryorchestration/internal/jsonExtractor"
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ func TestJSONProcess(t *testing.T) {
|
|||||||
|
|
||||||
queries := repository.New(db)
|
queries := repository.New(db)
|
||||||
|
|
||||||
extractor := jsonextractor.New(queries)
|
extractor := jsonextractor.NewExtractor(queries)
|
||||||
|
|
||||||
query := query.QueryRow{
|
query := queryprocessor.Query{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Type: query.TypeJsonExtractor,
|
Type: queryprocessor.TypeJsonExtractor,
|
||||||
RequiredQueryID: uuid.Nil,
|
RequiredQueryIDs: []uuid.UUID{},
|
||||||
Version: int32(1),
|
Version: int32(1),
|
||||||
}
|
}
|
||||||
entryValue := "value"
|
entryValue := "value"
|
||||||
|
|
||||||
@@ -97,13 +97,13 @@ func TestJSONProcessJSON(t *testing.T) {
|
|||||||
|
|
||||||
queries := repository.New(db)
|
queries := repository.New(db)
|
||||||
|
|
||||||
extractor := jsonextractor.New(queries)
|
extractor := jsonextractor.NewExtractor(queries)
|
||||||
|
|
||||||
query := query.QueryRow{
|
query := queryprocessor.Query{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Type: query.TypeJsonExtractor,
|
Type: queryprocessor.TypeJsonExtractor,
|
||||||
RequiredQueryID: uuid.Nil,
|
RequiredQueryIDs: []uuid.UUID{},
|
||||||
Version: int32(1),
|
Version: int32(1),
|
||||||
}
|
}
|
||||||
entryValue := "value"
|
entryValue := "value"
|
||||||
|
|
||||||
@@ -183,13 +183,13 @@ func TestJSONProcessResults(t *testing.T) {
|
|||||||
|
|
||||||
queries := repository.New(db)
|
queries := repository.New(db)
|
||||||
|
|
||||||
extractor := jsonextractor.New(queries)
|
extractor := jsonextractor.NewExtractor(queries)
|
||||||
|
|
||||||
query := query.QueryRow{
|
query := queryprocessor.Query{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Type: query.TypeJsonExtractor,
|
Type: queryprocessor.TypeJsonExtractor,
|
||||||
RequiredQueryID: uuid.Nil,
|
RequiredQueryIDs: []uuid.UUID{},
|
||||||
Version: int32(1),
|
Version: int32(1),
|
||||||
}
|
}
|
||||||
|
|
||||||
results := &[]result.Value{}
|
results := &[]result.Value{}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/query"
|
"queryorchestration/internal/query"
|
||||||
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -28,7 +29,7 @@ func TestGet(t *testing.T) {
|
|||||||
config := "{\"path\":\"example_path\"}"
|
config := "{\"path\":\"example_path\"}"
|
||||||
query := query.Query{
|
query := query.Query{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Type: query.TypeJsonExtractor,
|
Type: queryprocessor.TypeJsonExtractor,
|
||||||
Version: int32(1),
|
Version: int32(1),
|
||||||
RequiredQueryIDs: []uuid.UUID{
|
RequiredQueryIDs: []uuid.UUID{
|
||||||
uuid.New(),
|
uuid.New(),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package document_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -12,63 +12,63 @@ import (
|
|||||||
|
|
||||||
func TestParseDBQueryRow(t *testing.T) {
|
func TestParseDBQueryRow(t *testing.T) {
|
||||||
dbResult := repository.GetCollectorQueriesRow{
|
dbResult := repository.GetCollectorQueriesRow{
|
||||||
Collectorid: pgtype.UUID{},
|
Collectorid: pgtype.UUID{},
|
||||||
Queryid: pgtype.UUID{},
|
Queryid: pgtype.UUID{},
|
||||||
Requiredqueryid: pgtype.UUID{},
|
Requiredids: []pgtype.UUID{},
|
||||||
Type: repository.NullQuerytype{Valid: true, Querytype: repository.QuerytypeJsonExtractor},
|
Type: repository.NullQuerytype{Valid: true, Querytype: repository.QuerytypeJsonExtractor},
|
||||||
Queryversion: pgtype.Int4{},
|
Queryversion: pgtype.Int4{},
|
||||||
}
|
}
|
||||||
value, err := query.ParseDBQueryRow(&dbResult)
|
value, err := queryprocessor.ParseDBQuery(&dbResult)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, uuid.Nil, value.ID)
|
assert.Equal(t, uuid.Nil, value.ID)
|
||||||
assert.Equal(t, uuid.Nil, value.RequiredQueryID)
|
assert.Equal(t, []uuid.UUID{}, value.RequiredQueryIDs)
|
||||||
assert.Equal(t, int32(0), value.Version)
|
assert.Equal(t, int32(0), value.Version)
|
||||||
assert.Equal(t, query.Type(query.TypeJsonExtractor), value.Type)
|
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeJsonExtractor), value.Type)
|
||||||
|
|
||||||
dbResult.Type = repository.NullQuerytype{}
|
dbResult.Type = repository.NullQuerytype{}
|
||||||
_, err = query.ParseDBQueryRow(&dbResult)
|
_, err = queryprocessor.ParseDBQuery(&dbResult)
|
||||||
assert.EqualError(t, err, "invalid database query type")
|
assert.EqualError(t, err, "invalid database query type")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseDBNullType(t *testing.T) {
|
func TestParseDBNullType(t *testing.T) {
|
||||||
qType := repository.NullQuerytype{Valid: true, Querytype: repository.QuerytypeJsonExtractor}
|
qType := repository.NullQuerytype{Valid: true, Querytype: repository.QuerytypeJsonExtractor}
|
||||||
value, err := query.ParseDBNullType(qType)
|
value, err := queryprocessor.ParseDBNullType(qType)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, query.Type(query.TypeJsonExtractor), value)
|
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeJsonExtractor), value)
|
||||||
|
|
||||||
qType = repository.NullQuerytype{}
|
qType = repository.NullQuerytype{}
|
||||||
_, err = query.ParseDBNullType(qType)
|
_, err = queryprocessor.ParseDBNullType(qType)
|
||||||
assert.EqualError(t, err, "invalid database query type")
|
assert.EqualError(t, err, "invalid database query type")
|
||||||
|
|
||||||
qType = repository.NullQuerytype{Valid: true}
|
qType = repository.NullQuerytype{Valid: true}
|
||||||
_, err = query.ParseDBNullType(qType)
|
_, err = queryprocessor.ParseDBNullType(qType)
|
||||||
assert.EqualError(t, err, "invalid database query type")
|
assert.EqualError(t, err, "invalid database query type")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseDBType(t *testing.T) {
|
func TestParseDBType(t *testing.T) {
|
||||||
qType := repository.QuerytypeJsonExtractor
|
qType := repository.QuerytypeJsonExtractor
|
||||||
value, err := query.ParseDBType(qType)
|
value, err := queryprocessor.ParseDBType(qType)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, query.Type(query.TypeJsonExtractor), value)
|
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeJsonExtractor), value)
|
||||||
|
|
||||||
qType = repository.QuerytypeContextFull
|
qType = repository.QuerytypeContextFull
|
||||||
value, err = query.ParseDBType(qType)
|
value, err = queryprocessor.ParseDBType(qType)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, query.Type(query.TypeContextFull), value)
|
assert.Equal(t, queryprocessor.Type(queryprocessor.TypeContextFull), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestToDBQueryType(t *testing.T) {
|
func TestToDBQueryType(t *testing.T) {
|
||||||
dbQueryType := query.Type(query.TypeJsonExtractor)
|
dbQueryType := queryprocessor.Type(queryprocessor.TypeJsonExtractor)
|
||||||
value, err := query.ToDBQueryType(dbQueryType)
|
value, err := queryprocessor.ToDBQueryType(dbQueryType)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, value)
|
assert.Equal(t, repository.NullQuerytype{Querytype: repository.QuerytypeJsonExtractor, Valid: true}, value)
|
||||||
|
|
||||||
dbQueryType = query.Type(-1)
|
dbQueryType = queryprocessor.Type(-1)
|
||||||
_, err = query.ToDBQueryType(dbQueryType)
|
_, err = queryprocessor.ToDBQueryType(dbQueryType)
|
||||||
assert.EqualError(t, err, "invalid database query type")
|
assert.EqualError(t, err, "invalid database query type")
|
||||||
|
|
||||||
dbQueryType = query.Type(query.TypeContextFull)
|
dbQueryType = queryprocessor.Type(queryprocessor.TypeContextFull)
|
||||||
value, err = query.ToDBQueryType(dbQueryType)
|
value, err = queryprocessor.ToDBQueryType(dbQueryType)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, repository.NullQuerytype{Querytype: repository.QuerytypeContextFull, Valid: true}, value)
|
assert.Equal(t, repository.NullQuerytype{Querytype: repository.QuerytypeContextFull, Valid: true}, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"queryorchestration/internal/collector"
|
"queryorchestration/internal/collector"
|
||||||
"queryorchestration/internal/database"
|
"queryorchestration/internal/database"
|
||||||
"queryorchestration/internal/database/repository"
|
"queryorchestration/internal/database/repository"
|
||||||
"queryorchestration/internal/query"
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
||||||
"queryorchestration/internal/queryQueue"
|
"queryorchestration/internal/queryQueue"
|
||||||
"queryorchestration/internal/result"
|
"queryorchestration/internal/result"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -56,24 +56,27 @@ func TestQueue(t *testing.T) {
|
|||||||
querySixVersion := int32(6)
|
querySixVersion := int32(6)
|
||||||
contextID := uuid.New()
|
contextID := uuid.New()
|
||||||
contextVersion := int32(1)
|
contextVersion := int32(1)
|
||||||
collectorQueries := []query.QueryRow{
|
collectorQueries := []queryprocessor.Query{
|
||||||
{ID: contextID, Type: query.TypeContextFull, RequiredQueryID: uuid.Nil, Version: contextVersion},
|
{ID: contextID, Type: queryprocessor.TypeContextFull, RequiredQueryIDs: []uuid.UUID{}, Version: contextVersion},
|
||||||
{ID: queryOneID, Type: query.TypeJsonExtractor, RequiredQueryID: contextID, Version: queryOneVersion},
|
{ID: queryOneID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{contextID}, Version: queryOneVersion},
|
||||||
{ID: queryTwoID, Type: query.TypeJsonExtractor, RequiredQueryID: queryOneID, Version: queryTwoVersion},
|
{ID: queryTwoID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{queryOneID}, Version: queryTwoVersion},
|
||||||
{ID: queryThreeID, Type: query.TypeJsonExtractor, RequiredQueryID: queryOneID, Version: queryThreeVersion},
|
{ID: queryThreeID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{queryOneID}, Version: queryThreeVersion},
|
||||||
{ID: queryFourID, Type: query.TypeJsonExtractor, RequiredQueryID: contextID, Version: queryFourVersion},
|
{ID: queryFourID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{contextID}, Version: queryFourVersion},
|
||||||
{ID: queryFiveID, Type: query.TypeJsonExtractor, RequiredQueryID: querySixID, Version: queryFiveVersion},
|
{ID: queryFiveID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{querySixID}, Version: queryFiveVersion},
|
||||||
{ID: querySixID, Type: query.TypeJsonExtractor, RequiredQueryID: contextID, Version: querySixVersion},
|
{ID: querySixID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{contextID}, Version: querySixVersion},
|
||||||
}
|
}
|
||||||
|
|
||||||
rows := pgxmock.NewRows([]string{"collectorId", "queryId", "type", "requiredQueryId", "queryVersion"})
|
rows := pgxmock.NewRows([]string{"collectorId", "queryId", "type", "queryVersion", "requiredIds"})
|
||||||
for _, q := range collectorQueries {
|
for _, q := range collectorQueries {
|
||||||
dbID := database.MustToDBUUID(q.ID)
|
dbID := database.MustToDBUUID(q.ID)
|
||||||
dbReqID := database.MustToDBUUID(q.RequiredQueryID)
|
dbReqIDs := make([]pgtype.UUID, len(q.RequiredQueryIDs))
|
||||||
ty, err := query.ToDBQueryType(q.Type)
|
for index, id := range q.RequiredQueryIDs {
|
||||||
|
dbReqIDs[index] = database.MustToDBUUID(id)
|
||||||
|
}
|
||||||
|
ty, err := queryprocessor.ToDBQueryType(q.Type)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
rows = rows.
|
rows = rows.
|
||||||
AddRow(dbCollectorID, dbID, ty, dbReqID, pgtype.Int4{Int32: int32(q.Version), Valid: true})
|
AddRow(dbCollectorID, dbID, ty, pgtype.Int4{Int32: int32(q.Version), Valid: true}, dbReqIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorID).WillReturnRows(rows)
|
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorID).WillReturnRows(rows)
|
||||||
@@ -86,12 +89,12 @@ func TestQueue(t *testing.T) {
|
|||||||
{ID: uuid.New(), QueryID: queryOneID, QueryVersion: queryOneVersion - 1},
|
{ID: uuid.New(), QueryID: queryOneID, QueryVersion: queryOneVersion - 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedQueries := []query.QueryRow{
|
expectedQueries := []queryprocessor.Query{
|
||||||
{ID: querySixID, Type: query.TypeJsonExtractor, RequiredQueryID: contextID, Version: querySixVersion},
|
{ID: querySixID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{contextID}, Version: querySixVersion},
|
||||||
{ID: queryFiveID, Type: query.TypeJsonExtractor, RequiredQueryID: querySixID, Version: queryFiveVersion},
|
{ID: queryFiveID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{querySixID}, Version: queryFiveVersion},
|
||||||
{ID: queryOneID, Type: query.TypeJsonExtractor, RequiredQueryID: contextID, Version: queryOneVersion},
|
{ID: queryOneID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{contextID}, Version: queryOneVersion},
|
||||||
{ID: queryThreeID, Type: query.TypeJsonExtractor, RequiredQueryID: queryOneID, Version: queryThreeVersion},
|
{ID: queryThreeID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{queryOneID}, Version: queryThreeVersion},
|
||||||
{ID: queryTwoID, Type: query.TypeJsonExtractor, RequiredQueryID: queryOneID, Version: queryTwoVersion},
|
{ID: queryTwoID, Type: queryprocessor.TypeJsonExtractor, RequiredQueryIDs: []uuid.UUID{queryOneID}, Version: queryTwoVersion},
|
||||||
}
|
}
|
||||||
|
|
||||||
docID := uuid.New()
|
docID := uuid.New()
|
||||||
|
|||||||
Reference in New Issue
Block a user