foobar

package
v0.0.0-...-8832f83 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config interface{}) (error, dbconnector.DatabaseConnector)

Types

type Config

type Config struct {
	Host string
	Port int
}

Config represents the config outline for Foobar. The Database config shoud be of the following form:

"database_config" : {
    "host": "127.0.0.1",
    "port": 9080
}

Notice that the port is the GRPC-port.

type Foobar

type Foobar struct {
	// contains filtered or unexported fields
}

Foobar has some basic variables. This is mandatory, only change it if you need aditional, global variables

func (*Foobar) AddAction

func (f *Foobar) AddAction(ctx context.Context, action *models.Action, UUID strfmt.UUID) error

AddAction adds an action to the Foobar database with the given UUID. Takes the action and a UUID as input. Action is already validated against the ontology

func (*Foobar) AddActionsBatch

func (f *Foobar) AddActionsBatch(ctx context.Context, actions batchmodels.Actions) error

AddActionsBatch can be used for imports of large datasets. There is no fixed batch size, each connector can decide for themselves to split up the incoming batch into smaller chunks. For example the Janusgraph connector makes this cut at 50 items as this has proven to be a good threshold for that particular connector.

Note that every action in the batchmodels.Actions list also has an error field. The connector must check whether there already is an error in one of the items. This error could for example indicate a failed validation. Items that have failed prior to making it to the connector are not removed on purpose, so that the return result to the user matches their original request in both length and order.

The connector can decide - based on the batching consistency promises it makes to the user - whether to fail (and not import) the entire batch or only to skip the ones which failed validation

func (*Foobar) AddClass

func (f *Foobar) AddClass(ctx context.Context, kind kind.Kind, class *models.SemanticSchemaClass) error

Add a class to the Thing or Action schema, depending on the kind parameter.

func (*Foobar) AddProperty

func (f *Foobar) AddProperty(ctx context.Context, kind kind.Kind, className string, prop *models.SemanticSchemaClassProperty) error

func (*Foobar) AddThing

func (f *Foobar) AddThing(ctx context.Context, thing *models.Thing, UUID strfmt.UUID) error

AddThing adds a thing to the Foobar database with the given UUID. Takes the thing and a UUID as input. Thing is already validated against the ontology

func (*Foobar) AddThingsBatch

func (f *Foobar) AddThingsBatch(ctx context.Context, things batchmodels.Things) error

AddThingsBatch can be used for imports of large datasets. There is no fixed batch size, each connector can decide for themselves to split up the incoming batch into smaller chunks. For example the Janusgraph connector makes this cut at 50 items as this has proven to be a good threshold for that particular connector.

Note that every thing in the batchmodels.Things list also has an error field. The connector must check whether there already is an error in one of the items. This error could for example indicate a failed validation. Items that have failed prior to making it to the connector are not removed on purpose, so that the return result to the user matches their original request in both length and order.

The connector can decide - based on the batching consistency promises it makes to the user - whether to fail (and not import) the entire batch or only to skip the ones which failed validation

func (*Foobar) Attach

func (f *Foobar) Attach(ctx context.Context) (context.Context, error)

Attach can attach something to the request-context

func (*Foobar) Connect

func (f *Foobar) Connect() error

Connect creates a connection to the database and tables if not already available. The connections could not be closed because it is used more often.

func (*Foobar) DeleteAction

func (f *Foobar) DeleteAction(ctx context.Context, action *models.Action, UUID strfmt.UUID) error

DeleteAction deletes the Action in the DB at the given UUID.

func (*Foobar) DeleteThing

func (f *Foobar) DeleteThing(ctx context.Context, thing *models.Thing, UUID strfmt.UUID) error

DeleteThing deletes the Thing in the DB at the given UUID.

func (*Foobar) DropClass

func (f *Foobar) DropClass(ctx context.Context, kind kind.Kind, className string) error

Drop a class from the schema.

func (*Foobar) DropProperty

func (f *Foobar) DropProperty(ctx context.Context, kind kind.Kind, className string, propName string) error

func (*Foobar) GetAction

func (f *Foobar) GetAction(ctx context.Context, UUID strfmt.UUID, actionResponse *models.ActionGetResponse) error

GetAction fills the given ActionGetResponse with the values from the database, based on the given UUID.

func (*Foobar) GetActions

func (f *Foobar) GetActions(ctx context.Context, UUIDs []strfmt.UUID, actionsResponse *models.ActionsListResponse) error

GetActions fills the given ActionsListResponse with the values from the database, based on the given UUIDs.

func (*Foobar) GetThing

func (f *Foobar) GetThing(ctx context.Context, UUID strfmt.UUID, thingResponse *models.ThingGetResponse) error

GetThing fills the given ThingGetResponse with the values from the database, based on the given UUID.

func (*Foobar) GetThings

func (f *Foobar) GetThings(ctx context.Context, UUIDs []strfmt.UUID, thingResponse *models.ThingsListResponse) error

GetThings fills the given ThingsListResponse with the values from the database, based on the given UUIDs.

func (*Foobar) HistoryAction

func (f *Foobar) HistoryAction(ctx context.Context, UUID strfmt.UUID, history *models.ActionHistory) error

HistoryAction fills the history of a Action based on its UUID

func (*Foobar) HistoryThing

func (f *Foobar) HistoryThing(ctx context.Context, UUID strfmt.UUID, history *models.ThingHistory) error

HistoryThing fills the history of a thing based on its UUID

func (*Foobar) Init

func (f *Foobar) Init(ctx context.Context) error

Init 1st initializes the schema in the database and 2nd creates a root key.

func (*Foobar) ListActions

func (f *Foobar) ListActions(ctx context.Context, first int, offset int, wheres []*connutils.WhereQuery, actionsResponse *models.ActionsListResponse) error

ListActions fills the ActionReponse with a list of all actions

func (*Foobar) ListThings

func (f *Foobar) ListThings(ctx context.Context, first int, offset int, wheres []*connutils.WhereQuery, thingsResponse *models.ThingsListResponse) error

ListThings fills the given ThingsListResponse with the values from the database, based on the given parameters.

func (*Foobar) LocalAggregate

func (f *Foobar) LocalAggregate(info *aggregate.Params) (interface{}, error)

LocalAggregate resolves a GraphQL request to aggregate info about a single Class grouped by a property like so:

`{ Local { Aggregate { Things { City(groupBy: ["isCapital"]) { population { mean } } } } } }`

Where "City" is the particular className of kind "Thing". In the example above the user asked to resolve one property named "population". On this particular property the aggregation info "mean" is requested. In addition the "City" class is grouped by the "isCapital" property. So overall the user wants to known what is the mean population of cities which are capitals and what is the mean population of cities which are not capitals? This information is contained in the Params, together with pagination and filter information. Based on this info, the foobar connector can resolve the request. It should resolve to a []map[string]interface{} that can be consumed by the respective resolver in graphqlapi/local/aggregate

An example for a return value matching the above query could look like:

[]interface{}{
	map[string]interface{}{
		"population": map[string]interface{}{
			"mean": 1.2e+06,
		},
		"groupedBy": map[string]interface{}{
			"value": "false",
			"path": []interface{}{
				"isCapital",
			},
		},
	},
	map[string]interface{}{
		"population": map[string]interface{}{
			"mean": 2.635e+06,
		},
		"groupedBy": map[string]interface{}{
			"value": "true",
			"path": []interface{}{
				"isCapital",
			},
		},
	},
}

func (*Foobar) LocalFetchKindClass

func (f *Foobar) LocalFetchKindClass(info *fetch.Params) (interface{}, error)

LocalFetchKindClass TODO: Add proper docs

func (*Foobar) LocalGetClass

func (f *Foobar) LocalGetClass(info *get.Params) (interface{}, error)

LocalGetClass resolves a GraphQL request about a single Class like so

`{ Local { Get { Things { City { population } } } } }`

Where "City" is the particular className of kind "Thing". In the example above the user asked to resolve one property named "population". This information is contained in the Params, together with pagination and filter information. Based on this info, the foobar connector can resolve the request. It should resolve to a []map[string]interface{} that can be consumed by the respective resolver in graphqlapi/local/get.

An example matching the return value to the query above could look like:

[]interface{}{
 map[string]interface {}{
  "population": 1800000,
 },
 map[string]interface {}{
  "population": 600000,
 },
}

func (*Foobar) LocalGetMeta

func (f *Foobar) LocalGetMeta(info *getmeta.Params) (interface{}, error)

LocalGetMeta resolves a GraphQL request to retrieve meta info about a single Class like so:

`{ Local { GetMeta { Things { City { population { count } } } } } }`

Where "City" is the particular className of kind "Thing". In the example above the user asked to resolve one property named "population". On this particular property the meta info "count" is requested, i.e. how many "City" classes have the property "count" set? This information is contained in the Params, together with pagination and filter information. Based on this info, the foobar connector can resolve the request. It should resolve to a map[string]interface{} that can be consumed by the respective resolver in graphqlapi/local/getmeta.

An example for a return value matching the above query could look like:

map[string]interface{}{
	"population": map[string]interface{}{
		"count": 4,
	},
}

func (*Foobar) MoveToHistoryAction

func (f *Foobar) MoveToHistoryAction(ctx context.Context, action *models.Action, UUID strfmt.UUID, deleted bool) error

MoveToHistoryAction moves an action to history

func (*Foobar) MoveToHistoryThing

func (f *Foobar) MoveToHistoryThing(ctx context.Context, thing *models.Thing, UUID strfmt.UUID, deleted bool) error

MoveToHistoryThing moves a thing to history

func (*Foobar) SetMessaging

func (f *Foobar) SetMessaging(m *messages.Messaging)

SetMessaging is used to send messages to the service Available message types are: f.messaging.Infomessage ...DebugMessage ...ErrorMessage ...ExitError (also exits the service) ...InfoMessage

func (*Foobar) SetSchema

func (f *Foobar) SetSchema(schemaInput schema.Schema)

SetSchema takes actionSchema and thingsSchema as an input and makes them available globally at f.schema

func (*Foobar) SetServerAddress

func (f *Foobar) SetServerAddress(addr string)

SetServerAddress is used to fill in a global variable with the server address, but can also be used to do some custom actions. Does not return anything

func (*Foobar) SetState

func (f *Foobar) SetState(ctx context.Context, state json.RawMessage)

SetState is called by a connector when it has updated it's internal state that needs to be shared across all connectors in other Weaviate instances.

func (*Foobar) SetStateManager

func (f *Foobar) SetStateManager(manager connector_state.StateManager)

SetStateManager links a connector to this state manager. When the internal state of some connector is updated, this state connector will call SetState on the provided conn.

func (*Foobar) UpdateAction

func (f *Foobar) UpdateAction(ctx context.Context, action *models.Action, UUID strfmt.UUID) error

UpdateAction updates the Thing in the DB at the given UUID.

func (*Foobar) UpdateClass

func (f *Foobar) UpdateClass(ctx context.Context, kind kind.Kind, className string, newClassName *string, newKeywords *models.SemanticSchemaKeywords) error

func (*Foobar) UpdateProperty

func (f *Foobar) UpdateProperty(ctx context.Context, kind kind.Kind, className string, propName string, newName *string, newKeywords *models.SemanticSchemaKeywords) error

func (*Foobar) UpdatePropertyAddDataType

func (j *Foobar) UpdatePropertyAddDataType(ctx context.Context, kind kind.Kind, className string, propName string, newDataType string) error

func (*Foobar) UpdateThing

func (f *Foobar) UpdateThing(ctx context.Context, thing *models.Thing, UUID strfmt.UUID) error

UpdateThing updates the Thing in the DB at the given UUID.

Jump to

Keyboard shortcuts

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