示例#1
0
        public static IGremlinQueryExecutionPipeline UseWebSocketExecutor(
            this IGremlinQueryExecutionPipeline pipeline,
            string hostname,
            int port        = 8182,
            bool enableSsl  = false,
            string username = null,
            string password = null,
            GraphsonVersion graphsonVersion = GraphsonVersion.V2,
            IReadOnlyDictionary <Type, IGraphSONSerializer> additionalGraphsonSerializers       = null,
            IReadOnlyDictionary <string, IGraphSONDeserializer> additionalGraphsonDeserializers = null,
            ILogger logger = null)
        {
            var actualAdditionalGraphsonSerializers   = additionalGraphsonSerializers ?? ImmutableDictionary <Type, IGraphSONSerializer> .Empty;
            var actualAdditionalGraphsonDeserializers = additionalGraphsonDeserializers ?? ImmutableDictionary <string, IGraphSONDeserializer> .Empty;

            return(pipeline
                   .UseWebSocketExecutor(
                       () => new GremlinClient(
                           new GremlinServer(hostname, port, enableSsl, username, password),
                           graphsonVersion == GraphsonVersion.V2
                            ? new GraphSON2Reader(actualAdditionalGraphsonDeserializers)
                            : (GraphSONReader) new GraphSON3Reader(actualAdditionalGraphsonDeserializers),
                           graphsonVersion == GraphsonVersion.V2
                            ? new GraphSON2Writer(actualAdditionalGraphsonSerializers)
                            : (GraphSONWriter) new GraphSON3Writer(actualAdditionalGraphsonSerializers),
                           graphsonVersion == GraphsonVersion.V2
                            ? GremlinClient.GraphSON2MimeType
                            : GremlinClient.DefaultMimeType),
                       logger));
        }
        public static IGremlinQueryExecutionPipeline UseWebSocketExecutor(
            this IGremlinQueryExecutionPipeline pipeline,
            Uri uri,
            string?username = null,
            string?password = null,
            string alias    = "g",
            GraphsonVersion graphsonVersion = GraphsonVersion.V2,
            IReadOnlyDictionary <Type, IGraphSONSerializer>?additionalGraphsonSerializers       = null,
            IReadOnlyDictionary <string, IGraphSONDeserializer>?additionalGraphsonDeserializers = null,
            ILogger?logger = null)
        {
            var actualAdditionalGraphsonSerializers   = additionalGraphsonSerializers ?? ImmutableDictionary <Type, IGraphSONSerializer> .Empty;
            var actualAdditionalGraphsonDeserializers = additionalGraphsonDeserializers ?? ImmutableDictionary <string, IGraphSONDeserializer> .Empty;

            if (!"ws".Equals(uri.Scheme, StringComparison.OrdinalIgnoreCase) && !"wss".Equals(uri.Scheme, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException();
            }

            return(pipeline
                   .UseWebSocketExecutor(
                       () => new GremlinClient(
                           new GremlinServer((uri.Host + uri.AbsolutePath).TrimEnd('/'), uri.Port, "wss".Equals(uri.Scheme, StringComparison.OrdinalIgnoreCase), username, password),
                           graphsonVersion == GraphsonVersion.V2
                            ? new GraphSON2Reader(actualAdditionalGraphsonDeserializers)
                            : (GraphSONReader) new GraphSON3Reader(actualAdditionalGraphsonDeserializers),
                           graphsonVersion == GraphsonVersion.V2
                            ? new GraphSON2Writer(actualAdditionalGraphsonSerializers)
                            : (GraphSONWriter) new GraphSON3Writer(actualAdditionalGraphsonSerializers),
                           graphsonVersion == GraphsonVersion.V2
                            ? GremlinClient.GraphSON2MimeType
                            : GremlinClient.DefaultMimeType),
                       alias,
                       logger));
        }
示例#3
0
 public GremlinClientEx(GremlinServer gremlinServer, GraphsonVersion version) : base(
         gremlinServer,
         version == GraphsonVersion.V2
         ? new GraphSON2Reader()
         : (GraphSONReader) new GraphSON3Reader(),
         version == GraphsonVersion.V2
         ? new GraphSON2Writer()
         : (GraphSONWriter) new GraphSON3Writer(),
         version == GraphsonVersion.V2
         ? GraphSON2MimeType
         : DefaultMimeType)
 {
 }
示例#4
0
 public static IConfigurableGremlinQuerySource UseWebSocket(
     this IConfigurableGremlinQuerySource source,
     string hostname,
     GraphsonVersion graphsonVersion,
     int port        = 8182,
     bool enableSsl  = false,
     string username = null,
     string password = null,
     IReadOnlyDictionary <Type, IGraphSONSerializer> additionalGraphsonSerializers       = null,
     IReadOnlyDictionary <string, IGraphSONDeserializer> additionalGraphsonDeserializers = null)
 {
     return(source.ConfigureExecutionPipeline(conf => conf
                                              .UseSerializer(GremlinQuerySerializer.Groovy)
                                              .UseWebSocketExecutor(hostname, port, enableSsl, username, password, graphsonVersion, additionalGraphsonSerializers, additionalGraphsonDeserializers, source.Logger)
                                              .UseDeserializer(GremlinQueryExecutionResultDeserializer.Graphson)));
 }
 public static IGremlinQuerySource UseWebSocket(
     this IGremlinQuerySource source,
     Uri uri,
     GraphsonVersion graphsonVersion,
     string?username = null,
     string?password = null,
     string alias    = "g",
     IReadOnlyDictionary <Type, IGraphSONSerializer>?additionalGraphsonSerializers       = null,
     IReadOnlyDictionary <string, IGraphSONDeserializer>?additionalGraphsonDeserializers = null)
 {
     return(source
            .ConfigureEnvironment(environment => environment
                                  .ConfigureExecutionPipeline(conf => conf
                                                              .UseWebSocketExecutor(uri, username, password, alias, graphsonVersion, additionalGraphsonSerializers, additionalGraphsonDeserializers, environment.Logger)
                                                              .UseDeserializer(GremlinQueryExecutionResultDeserializer.Graphson))));
 }
 public static IGremlinQuerySource UseGremlinServer(this IGremlinQuerySource source,
                                                    Uri uri,
                                                    GraphsonVersion graphsonVersion,
                                                    string?username = null,
                                                    string?password = null,
                                                    string alias    = "g",
                                                    IReadOnlyDictionary <Type, IGraphSONSerializer>?additionalGraphsonSerializers       = null,
                                                    IReadOnlyDictionary <string, IGraphSONDeserializer>?additionalGraphsonDeserializers = null)
 {
     return(source
            .UseWebSocket(
                uri,
                graphsonVersion,
                username,
                password,
                alias,
                additionalGraphsonSerializers,
                additionalGraphsonDeserializers));
 }
示例#7
0
 public static IConfigurableGremlinQuerySource WithRemote(this IConfigurableGremlinQuerySource source, GremlinServer server, GraphsonVersion graphsonVersion)
 {
     return(source.WithExecutor(
                new WebSocketGremlinQueryExecutor <GroovyGremlinQueryElementVisitor>(
                    new GremlinClientEx(
                        server,
                        graphsonVersion),
                    new DefaultGraphsonSerializerFactory(),
                    source.Logger)));
 }
示例#8
0
 public static IConfigurableGremlinQuerySource WithRemote(this IConfigurableGremlinQuerySource source, string hostname, GraphsonVersion graphsonVersion, int port = 8182, bool enableSsl = false, string username = null, string password = null)
 {
     return(source.WithRemote(
                new GremlinServer(hostname, port, enableSsl, username, password),
                graphsonVersion));
 }