query

package
v0.0.0-...-ff244ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AsyncTypes = []string{"AsyncAggregation"}

Functions

func ConceptsToString

func ConceptsToString(concepts []Concept) string

func DeleteAsyncDataT

func DeleteAsyncDataT(queryid string) error

func FetchAsyncDataDA

func FetchAsyncDataDA(queryid string, indexLayer int, indexDA int) (map[string]interface{}, error)

func FetchAsyncDataT

func FetchAsyncDataT(queryid string) (map[string]interface{}, error)

func FetchAsyncMetadata

func FetchAsyncMetadata(queryid string) ([]metadata.TaskMetadata, error)

func IsAsyncTaskDAExisting

func IsAsyncTaskDAExisting(queryid string, indexLayer int, indexDA int) (bool, error)

Types

type AggregationFunction

type AggregationFunction struct {
	Function string                 `json:"func,omitempty"`
	Args     map[string]interface{} `json:"args,omitempty"`
}

AggregationFunction is created by DA from AggregationJob

type AggregationJob

type AggregationJob struct {
	Job  string                 `json:"job,omitempty"`
	Args map[string]interface{} `json:"args,omitempty"`
}

AggregationJob is transmitted by the Querier

type AggregationPatch

type AggregationPatch struct {
	Patch string                 `json:"patch,omitempty"`
	Args  map[string]interface{} `json:"args,omitempty"`
}

AggregationPatch is created by DA from AggregationJob

type AsyncTask

type AsyncTask struct {
	AsyncID      string                `json:"_id,omitempty"`
	AsyncRev     string                `json:"_rev,omitempty"`
	AsyncType    AsyncType             `json:"async_type,omitempty"`
	QueryID      string                `json:"query_id"`
	TaskMetadata metadata.TaskMetadata `json:"task_metadata"`
	// Attributes used for AsyncAggregation
	IndexLayer int                    `json:"da_layer_id"`
	IndexDA    int                    `json:"da_id"`
	StateDA    State                  `json:"da_state,omitempty"`
	ResultDA   map[string]interface{} `json:"da_result,omitempty"`
	// Attributes used for AsyncQueryTarget or AsyncSendData
	NumberOfTargets int                      `json:"t_number_targets,omitempty"`
	Data            []map[string]interface{} `json:"t_data,omitempty"`
}

func NewAsyncTask

func NewAsyncTask(queryid string, asyncType AsyncType, integers ...int) (AsyncTask, error)

func RetrieveAsyncTaskDA

func RetrieveAsyncTaskDA(queryid string, indexLayer int, indexDA int) (AsyncTask, error)

func (*AsyncTask) Clone

func (as *AsyncTask) Clone() couchdb.Doc

Clone copy a brand new version of the doc

func (*AsyncTask) DocType

func (as *AsyncTask) DocType() string

DocType returns the DocType

func (*AsyncTask) GetStateDA

func (as *AsyncTask) GetStateDA() State

GetStateDA returns the state of DA

func (*AsyncTask) ID

func (as *AsyncTask) ID() string

ID returns the Doc ID

func (*AsyncTask) Rev

func (as *AsyncTask) Rev() string

Rev returns the doc's version

func (*AsyncTask) SetData

func (as *AsyncTask) SetData(data ...map[string]interface{}) error

func (*AsyncTask) SetFinished

func (as *AsyncTask) SetFinished() error

func (*AsyncTask) SetID

func (as *AsyncTask) SetID(id string)

SetID set the ID

func (*AsyncTask) SetRev

func (as *AsyncTask) SetRev(rev string)

SetRev set the version

type AsyncType

type AsyncType int
const (
	AsyncAggregation AsyncType = iota
	AsyncQueryTarget
)

type Concept

type Concept struct {
	EncryptedConcept []byte `json:"enc_concept,omitempty"`
	Hash             []byte `json:"hash,omitempty"`
}

type FindParams

type FindParams struct {
	Selector map[string]interface{} `json:"selector"`
	Skip     int                    `json:"skip,omitempty"`
	Limit    int                    `json:"limit,omitempty"`
	Sort     []map[string]string    `json:"sort,omitempty"`
}

FindParams describes to query to make to stacks It follows CouchDB conventions

type InputCI

type InputCI struct {
	IsEncrypted       bool      `json:"is_encrypted,omitempty"`
	Concepts          []string  `json:"concepts,omitempty"`
	EncryptedConcepts []Concept `json:"enc_concepts,omitempty"`
}

type InputDA

type InputDA struct {
	QueryID       string                `json:"queryid"`
	AggregationID [2]int                `json:"aggregationid,omitempty"`
	ConductorURL  url.URL               `json:"conductor_url"`
	IsEncrypted   bool                  `json:"is_encrypted"`
	EncryptedJobs []byte                `json:"enc_jobs,omitempty"`
	EncryptedData []byte                `json:"enc_data,omitempty"`
	TaskMetadata  metadata.TaskMetadata `json:"metadata_task,omitempty"`
}

type InputNewQuery

type InputNewQuery struct {
	Concepts               []string          `json:"concepts,omitempty"`
	PseudoConcepts         map[string]string `json:"pseudo_concepts,omitempty"`
	IsEncrypted            bool              `json:"is_encrypted"`
	LocalQuery             LocalQuery        `json:"local_query,omitempty"`
	TargetProfile          string            `json:"target_profile,omitempty"`
	LayersDA               []LayerDA         `json:"layers_da,omitempty"`
	EncryptedLocalQuery    []byte            `json:"enc_local_query,omitempty"`
	EncryptedConcepts      []Concept         `json:"enc_concepts,omitempty"`
	EncryptedTargetProfile []byte            `json:"enc_operation,omitempty"`
}

type InputPatchQuery

type InputPatchQuery struct {
	IsEncrypted bool     `json:"is_encrypted"`
	Role        string   `json:"role"`
	OutDA       OutputDA `json:"output_da,omitempty"`
	OutT        OutputT  `json:"output_t,omitempty"`
}

type InputT

type InputT struct {
	IsEncrypted         bool                  `json:"is_encrypted,omitempty"`
	EncryptedLocalQuery []byte                `json:"enc_local_query,omitempty"`
	EncryptedTargets    []byte                `json:"enc_addresses,omitempty"`
	ConductorURL        url.URL               `json:"conductor_url"`
	QueryID             string                `json:"queryid,omitempty"`
	TaskMetadata        metadata.TaskMetadata `json:"metadata_task,omitempty"`
}

InputT contains information received by Target's enclave

type InputTF

type InputTF struct {
	IsEncrypted               bool                  `json:"is_encrypted"`
	EncryptedListsOfAddresses map[string][]byte     `json:"enc_instances,omitempty"`
	EncryptedTargetProfile    []byte                `json:"enc_operation,omitempty"`
	TaskMetadata              metadata.TaskMetadata `json:"metadata_task,omitempty"`
}

InputTF contains a map that associate every concept to a list of Addresses and a operation to compute to retrive the final list

type Instance

type Instance struct {
	Domain      string `json:"domain"`
	TokenBearer string `json:"token_bearer"`
	Version     int    `json:"version"`
}

Instance describes the location of an instance and the token it had created When Target received twice the same Instance, it needs to be able to consider the more recent item

type LayerDA

type LayerDA struct {
	Data          []map[string]interface{} `json:"layer_data,omitempty"`
	Size          int                      `json:"layer_size"`
	EncryptedJobs []byte                   `json:"layer_enc_jobs"`
	Jobs          []AggregationJob         `json:"layer_jobs"`
}

type LocalQuery

type LocalQuery struct {
	FindRequest FindParams             `json:"findrequest"`
	Doctype     string                 `json:"doctype"`
	Index       map[string]interface{} `json:"index"`
	Limit       int                    `json:"limit,omitempty"`
}

LocalQuery decribes which data the stack has to retrieve

type NodeType

type NodeType int

NodeType are the only possible nodes in Target Profile trees

const (
	// SingleNode are Target Profile's leafs
	SingleNode NodeType = iota
	// OrNode are unions between two lists
	OrNode
	// AndNode are intersections between two lists
	AndNode
)

type OperationTree

type OperationTree struct {
	Type      NodeType    `json:"type"`
	Value     string      `json:"value,omitempty"`
	LeftNode  interface{} `json:"left_node,omitempty"`
	RightNode interface{} `json:"right_node,omitempty"`
}

OperationTree allows the possibility to compute target profiles in a recursive way. OperationTree contains SingleNode, OrNode, AndNode SingleNodes have got a value field. A value is the name of a list of strings To compute the OperationTree, Compute method needs a map that matches names with list of encrypted addresses.

func (*OperationTree) Compute

func (o *OperationTree) Compute(listsOfAddresses map[string][]string) ([]string, error)

Compute compute the OperationTree and returns the list of encrypted addresses

func (*OperationTree) UnmarshalJSON

func (o *OperationTree) UnmarshalJSON(data []byte) error

UnmarshalJSON is used to load the OperationTree given by the Querier

type OutputCI

type OutputCI struct {
	Hashes       []Concept             `json:"hashes,omitempty"`
	TaskMetadata metadata.TaskMetadata `json:"metadata_task,omitempty"`
}

OutputCI contains a bool and the result

type OutputDA

type OutputDA struct {
	Results       map[string]interface{} `json:"results,omitempty"`
	QueryID       string                 `json:"queryid,omitempty"`
	AggregationID [2]int                 `json:"aggregationid,omitempty"`
	TaskMetadata  metadata.TaskMetadata  `json:"metadata_task,omitempty"`
}

type OutputT

type OutputT struct {
	Data         []map[string]interface{} `json:"data,omitempty"`
	QueryID      string                   `json:"queryid,omitempty"`
	TaskMetadata metadata.TaskMetadata    `json:"metadata_task,omitempty"`
}

OutputT is what Target returns to the conductor

type OutputTF

type OutputTF struct {
	EncryptedTargets []byte                `json:"enc_targets,omitempty"`
	TaskMetadata     metadata.TaskMetadata `json:"metadata_task,omitempty"`
}

OutputTF is what Target Finder send to the conductor

type StackQuery

type StackQuery struct {
	Domain          string     `json:"domain"`
	LocalQuery      LocalQuery `json:"local_query"`
	TokenBearer     string     `json:"token_bearer"`
	IsEncrypted     bool       `json:"is_encrypted"`
	ConductorURL    url.URL    `json:"conductor_url"`
	QueryID         string     `json:"queryid"`
	NumberOfTargets int        `json:"number_targets"`
}

StackQuery is all the information needed by the conductor's and stack to make a query

type State

type State int
const (
	Finished State = iota
	Waiting
	Running
	Failed
)

func FetchAsyncStateLayer

func FetchAsyncStateLayer(queryid string, indexLayer int, sizeLayer int) (State, error)

FetchAsyncStateLayer returns the state of the layer The function has to be the fastest as possible

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL