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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 public static IGremlinQueryExecutionPipeline UseCosmosDbExecutor(this IGremlinQueryExecutionPipeline pipeline, Uri uri, string database, string graphName, string authKey, ILogger logger)
 {
     return(pipeline
            .UseWebSocketExecutor(
                uri,
                $"/dbs/{database}/colls/{graphName}",
                authKey,
                "g",
                GraphsonVersion.V2,
                new Dictionary <Type, IGraphSONSerializer>
     {
         { typeof(TimeSpan), new TimeSpanSerializer() }
     },
Ejemplo n.º 4
0
 private static IGremlinQueryExecutionPipeline UseCosmosDbExecutor(this IGremlinQueryExecutionPipeline builder, string hostname, int port, bool enableSsl, string database, string graphName, string authKey, ILogger logger)
 {
     return(builder
            .UseWebSocketExecutor(
                hostname,
                port,
                enableSsl,
                $"/dbs/{database}/colls/{graphName}",
                authKey,
                GraphsonVersion.V2,
                new Dictionary <Type, IGraphSONSerializer>
     {
         { typeof(TimeSpan), new TimeSpanSerializer() }
     },