public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context) { // Tries to parse the context parameters and see if it belongs to this [CosmosDBTrigger] binder if (context == null) { throw new ArgumentNullException("context"); } ParameterInfo parameter = context.Parameter; CosmosDBCassandraTriggerAttribute attribute = parameter.GetCustomAttribute <CosmosDBCassandraTriggerAttribute>(inherit: false); if (attribute == null) { return(null); } string contactPoint = ResolveConfigurationValue(attribute.ContactPoint, nameof(attribute.ContactPoint)); string user = ResolveConfigurationValue(attribute.User, nameof(attribute.User)); string password = ResolveConfigurationValue(attribute.Password, nameof(attribute.Password)); ICosmosDBCassandraService cosmosDBCassandraService = _configProvider.GetService(contactPoint, user, password); return(Task.FromResult((ITriggerBinding) new CosmosDBCassandraTriggerBinding( parameter, ResolveAttributeValue(attribute.KeyspaceName), ResolveAttributeValue(attribute.TableName), attribute.StartFromBeginning, attribute.FeedPollDelay, cosmosDBCassandraService, _logger))); }
public CosmosDBCassandraTriggerBinding(ParameterInfo parameter, string keyspace, string table, bool startFromBeginning, int feedpolldelay, ICosmosDBCassandraService cosmosDBCassandraService, ILogger logger) { _keyspace = keyspace; _table = table; _cosmosDBCassandraService = cosmosDBCassandraService; _parameter = parameter; _startFromBeginning = startFromBeginning; _feedpolldelay = feedpolldelay; _logger = logger; }
public CosmosDBTriggerListener(ITriggeredFunctionExecutor executor, string functionId, string keyspace, string table, bool startFromBeginning, int feedpolldelay, ICosmosDBCassandraService cosmosDBCassandraService, ILogger logger) { this._logger = logger; this._executor = executor; this._functionId = functionId; this._keyspace = keyspace; this._table = table; this._startFromBeginning = startFromBeginning; this._defaultTimeSpan = feedpolldelay > 0 ? TimeSpan.FromMilliseconds(feedpolldelay) : TimeSpan.FromMilliseconds(5000); this._cosmosDBCassandraService = cosmosDBCassandraService; this._hostName = Guid.NewGuid().ToString(); }