example

package
v0.0.0-...-fa720cf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "example-graph",
	Short: "Load an example graph",
	Args:  cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		conn, err := gripql.Connect(rpc.ConfigWithDefaults(host), true)
		if err != nil {
			return err
		}

		resp, err := conn.ListGraphs()
		if err != nil {
			return err
		}
		if found(resp.Graphs, graph) {
			return fmt.Errorf("grip already contains a graph called %s", graph)
		}

		err = conn.AddGraph(graph)
		if err != nil {
			return err
		}

		elemChan := make(chan *gripql.GraphElement)
		wait := make(chan bool)
		go func() {
			if err := conn.BulkAdd(elemChan); err != nil {
				log.WithFields(log.Fields{"error": err}).Error("bulk add error")
			}
			wait <- false
		}()

		log.WithFields(log.Fields{"graph": graph}).Info("Loading example data into graph")
		for _, v := range example.SWVertices {
			elemChan <- &gripql.GraphElement{Graph: graph, Vertex: v}
		}
		for _, e := range example.SWEdges {
			elemChan <- &gripql.GraphElement{Graph: graph, Edge: e}
		}

		close(elemChan)
		<-wait

		return nil
	},
}

Cmd is the example loader command line definition

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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