static T DeserializeBadDataHelper <T, U>(CreationDelegate <U> creator) where U : Bond.IO.IInputStream, Bond.IO.ICloneable <U> { // Untagged protocol used to trigger errors more easily var reader = new SimpleBinaryReader <U>(creator(badData)); return(new Deserializer <SimpleBinaryReader <U> >(typeof(T)).Deserialize <T>(reader)); }
private static async Task DeployDataWorkerQueue(TextWriter writer, bool recreate = false) { // "dumpling-service data-worker queue path" // "dumpling-service bus connection string" var dataworkerQueuePath = NearbyConfig.Settings["dumpling-service data-worker queue path"]; var servicebusConnString = NearbyConfig.Settings["dumpling-service bus connection string"]; NamespaceManager manager = NamespaceManager.CreateFromConnectionString(servicebusConnString); CreationDelegate createQueue = async() => { writer.WriteLine("creating new dataworker queue"); await manager.CreateQueueAsync(dataworkerQueuePath); }; var exists = await manager.QueueExistsAsync(dataworkerQueuePath); if (exists && recreate) { writer.WriteLine("dataworker queue exists; deleting current instance"); await manager.DeleteQueueAsync(dataworkerQueuePath); createQueue(); } else if (!exists) { createQueue(); } else { writer.WriteLine($"'{dataworkerQueuePath}' exists already and we're not recreating"); } }
public static IInjectionBinding Make <T>(CreationDelegate _pattern) where T : class, IInjectingItem { return(new Binding <I>() { ConcreteType = typeof(T), InterfaceType = typeof(I), _delegate = _pattern }); }
public static void CreatePoolableBinding <Interface, Concrete>(CreationDelegate _creation, IPool _pool) where Interface : class, IInjectingItem, IPoolable where Concrete : class, IInjectingItem, IPoolable { ExistingEntry <Interface>().OnHasValue(x => Registry.Remove(x)); Binding <Interface> .Make <Concrete>(_creation) .WithPool(_pool) .AddTo(Registry.Add); }
/// <summary> /// This topic is used to route messages to the correct analysis machine for analytics. /// </summary> /// <returns></returns> private static async Task DeployAnalysisTopic(TextWriter writer, bool recreate = false) { var SubscriptionsAndConditions = new Dictionary <string, SqlFilter>() { { "ubuntu", new SqlFilter("target_os = 'ubuntu'") }, { "centos", new SqlFilter("target_os = 'centos' OR target_os = 'rhel' OR target_os = 'redhat'") }, { "windows", new SqlFilter("target_os = 'windows'") } }; // check if the topic exists, then create it. var nsManager = NamespaceManager.CreateFromConnectionString(NearbyConfig.Settings["dumpling-service bus connection string"]); var topicName = NearbyConfig.Settings["dumpling-service analysis topic path"]; CreationDelegate createTopic = async() => { var topicDescription = new TopicDescription(topicName); await nsManager.CreateTopicAsync(topicDescription); writer.WriteLine("topic created"); }; var exists = await nsManager.TopicExistsAsync(topicName); if (exists && recreate) { writer.WriteLine($"topic {topicName} deleting it"); await nsManager.DeleteTopicAsync(topicName); createTopic(); } else if (!exists) { createTopic(); } else { writer.WriteLine($"'{topicName}' exists and we are not recreating."); } // Topic is created, now we'll do the subscriptions. foreach (var subscription in SubscriptionsAndConditions) { // I use this to avoid repeating myself in the createSubscription(...) calls below. CreationDelegate createSubscription = async() => { SubscriptionDescription description = new SubscriptionDescription(topicName, subscription.Key); // When an item is retrieved from the subscription, a machine owns that lock, and then must clean up after it. // if the lock expires that machine will not be able to delete the message and it is possible for another machine to take it. description.LockDuration = TimeSpan.FromMinutes(5); // after 16 hours, dead letter any messages in the queue. In my experience this is necessary // because sometimes messages can get 'stuck' if they take too long to evaluate. We won't just delete // them though, we'll dead letter them. description.DefaultMessageTimeToLive = TimeSpan.FromHours(16); description.EnableDeadLetteringOnMessageExpiration = true; await nsManager.CreateSubscriptionAsync(description, subscription.Value); writer.WriteLine($"created subscription: {subscription.Key}"); }; // next we'll (re)create the subscriptions exists = await nsManager.SubscriptionExistsAsync(topicName, subscription.Key); if (exists && recreate) { writer.WriteLine($"'{subscription.Key}' already exists; deleting"); await nsManager.DeleteSubscriptionAsync(topicName, subscription.Key); createSubscription(); } else if (!exists) { createSubscription(); } else { writer.WriteLine($"'{subscription.Key}' already exists and we're not recreating."); } } }
public BuiltInOperator(string op, CreationDelegate factoryMethod, SchemaDelegate schemaMethod) { _operator = op; _factoryMethod = factoryMethod; _schemaMethod = schemaMethod; }
public Pool(CreationDelegate creator, int maxPoolItems) { m_items = new T[maxPoolItems < 32 ? maxPoolItems : 32]; m_maxPooledItems = maxPoolItems; m_create = creator; }
public static void CreateBinding <Interface, Concrete>(CreationDelegate _creation) where Interface : class, IInjectingItem where Concrete : class, IInjectingItem { ExistingEntry <Interface>().OnHasValue(x => Registry.Remove(x)); Binding <Interface> .Make <Concrete>(_creation).AddTo(Registry.Add); }