示例#1
0
        public Transport(
            IConnectionConfigurationValues configurationValues,
            IConnection connection,
            IElasticsearchSerializer serializer,
            IDateTimeProvider dateTimeProvider         = null,
            IMemoryStreamProvider memoryStreamProvider = null
            )
        {
            this.ConfigurationValues = configurationValues;
            this.Connection          = connection ?? new HttpConnection(configurationValues);
            this._serializer         = serializer ?? new ElasticsearchDefaultSerializer();
            this._connectionPool     = this.ConfigurationValues.ConnectionPool;

            this._dateTimeProvider     = dateTimeProvider ?? new DateTimeProvider();
            this._memoryStreamProvider = memoryStreamProvider ?? new MemoryStreamProvider();

            this._lastSniff = this._dateTimeProvider.Now();

            this.Settings.Serializer = this._serializer;

            this._requestHandler      = new RequestHandler(this.Settings, this._connectionPool, this.Connection, this._serializer, this._memoryStreamProvider, this);
            this._requestHandlerAsync = new RequestHandlerAsync(this.Settings, this._connectionPool, this.Connection, this._serializer, this._memoryStreamProvider, this);
            if (this._connectionPool.AcceptsUpdates && this.Settings.SniffsOnStartup)
            {
                Self.SniffClusterState();
            }
        }
示例#2
0
        public Transport(
            IConnectionConfigurationValues configurationValues,
            IConnection connection,
            IOrientdbSerializer serializer,
            IDateTimeProvider dateTimeProvider         = null,
            IMemoryStreamProvider memoryStreamProvider = null
            )
        {
            ConfigurationValues = configurationValues;
            Connection          = connection ?? new HttpConnection(configurationValues);
            //_serializer = serializer ?? new OrientdbDefaultSerializer();
            _serializer = serializer ?? new OrientdbSerializer();

            _connectionPool = ConfigurationValues.ConnectionPool;

            _dateTimeProvider     = dateTimeProvider ?? new DateTimeProvider();
            _memoryStreamProvider = memoryStreamProvider ?? new MemoryStreamProvider();

            _lastSniff = _dateTimeProvider.Now();

            Settings.Serializer = _serializer;

            _requestHandler = new RequestHandler(Settings, _connectionPool, Connection, _serializer,
                                                 _memoryStreamProvider, this);
            _requestHandlerAsync = new RequestHandlerAsync(Settings, _connectionPool, Connection, _serializer,
                                                           _memoryStreamProvider, this);
            if (_connectionPool.AcceptsUpdates && Settings.SniffsOnStartup)
            {
                Self.SniffClusterState();
            }
        }
示例#3
0
        public RouteHandler(HttpMethod method, string url, RequestHandlerAsync handler)
        {
            Method  = method;
            Url     = url;
            Handler = handler;
            var matchRoute = url;

            foreach (Match match in RouteParamRegex.Matches(url))
            {
                if (!match.Success || match.Value.Length <= 0)
                {
                    continue;
                }

                _routeParameters.Add(match.Value);
                matchRoute = matchRoute.Replace(match.Value, match.Value.EndsWith("?}") ?
                                                RouteOptionalParamReplacePattern :
                                                RouteRequiredParamReplacePattern);
            }
            matchRoute     = matchRoute.Replace("/", @"(\/*)");
            _rgxMatchRoute = new Regex(matchRoute, RegexOptions.IgnoreCase | RegexOptions.Compiled);
        }
示例#4
0
 public void Use(RequestHandlerAsync handler) => RegisterHandler("/", handler);
示例#5
0
 public void Register(short packetId, RequestHandlerAsync handler)
 {
     handlers.Add(packetId, handler);
 }