simonz-bq commented on a change in pull request #1556: URL: https://github.com/apache/tinkerpop/pull/1556#discussion_r806384003
########## File path: gremlin-go/driver/client.go ########## @@ -0,0 +1,87 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package gremlingo + +import ( + "golang.org/x/text/language" +) + +// ClientSettings is used to modify a Client's settings on initialization. +type ClientSettings struct { + TransporterType TransporterType + LogVerbosity LogVerbosity + Logger Logger + Language language.Tag +} + +// Client is used to connect and interact with a Gremlin-supported server. +type Client struct { + host string + port int + logHandler *logHandler + transporterType TransporterType + connection *connection +} + +// NewClient creates a Client and configures it with the given parameters. +func NewClient(host string, port int, configurations ...func(settings *ClientSettings)) *Client { + settings := &ClientSettings{ + TransporterType: Gorilla, + LogVerbosity: Info, + Logger: &defaultLogger{}, + Language: language.English, + } + for _, configuration := range configurations { + configuration(settings) + } + + logHandler := newLogHandler(settings.Logger, settings.LogVerbosity, settings.Language) + client := &Client{ + host: host, + port: port, + logHandler: logHandler, + transporterType: settings.TransporterType, + connection: nil, + } + return client +} + +// Close closes the client via connection +func (client *Client) Close() error { + return client.connection.close() +} + +// Submit submits a Gremlin script to the server and returns a ResultSet Review comment: As of MS2, it is no longer a synchronous call! ########## File path: gremlin-go/driver/request.go ########## @@ -0,0 +1,42 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package gremlingo + +import "github.com/google/uuid" + +const op = "eval" +const processor = "" + +// request represents a request to the server +type request struct { + requestID uuid.UUID `json:"requestId"` + op string `json:"op"` + processor string `json:"processor"` + args map[string]interface{} `json:"args"` +} + +func makeStringRequest(requestString string) (req request) { + return request{uuid.New(), op, processor, map[string]interface{}{ + "gremlin": requestString, + "aliases": map[string]interface{}{ + "g": "g", Review comment: TODO added and tracked. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
