public static ITaskClient GetTaskClient(Uri uri, string authToken, IBrokerInstrumentation instrumentationHandler, bool skipRaisePlanEvents) { var vssCrediential = new VssBasicCredential(string.Empty, authToken); return(skipRaisePlanEvents ? new TaskClientNoopPlanEvent(uri, vssCrediential, instrumentationHandler) : new TaskClient(uri, vssCrediential, instrumentationHandler)); }
public TaskClient(Uri baseUrl, VssCredentials credentials, IBrokerInstrumentation instrumentationHandler, int retryCount, int retryInterval) { var vssConnection = new VssConnection(baseUrl, credentials); this.client = vssConnection.GetClient <TaskHttpClient>(); this.instrumentationHandler = instrumentationHandler; this.vstsUrl = baseUrl.ToString(); this.retryer = Retryer.CreateRetryer(retryCount, TimeSpan.FromSeconds(retryInterval)); }
public VstsBrokerInstrumentation(IBrokerInstrumentation baseInstrumentation, ITaskClient taskClient, string hubName, Guid scopeIdentifier, Guid planId, int taskLogId, IDictionary <string, string> eventProperties) { this.baseInstrumentation = baseInstrumentation; this.taskClient = taskClient; this.scopeIdentifier = scopeIdentifier; this.planId = planId; this.taskLogId = taskLogId; this.hubName = hubName; this.baseEventProperties = eventProperties ?? new Dictionary <string, string>(); }
public VstsReportingHelper(VstsMessage vstsContext, IBrokerInstrumentation baseInstrumentation, IDictionary <string, string> eventProperties, string timelineRecordName = null) { this.vstsContext = vstsContext; this.baseInstrumentation = baseInstrumentation; this.timelineRecordName = timelineRecordName; this.eventProperties = this.vstsContext.GetMessageProperties().AddRange(eventProperties); this.CreateTaskHttpClient = (uri, authToken, instrumentationHelper, skipRaisePlanEvents) => TaskClientFactory.GetTaskClient(uri, authToken, instrumentationHelper, skipRaisePlanEvents); this.CreateBuildClient = (uri, authToken) => new BuildClient(uri, new VssBasicCredential(string.Empty, authToken)); this.CreateReleaseClient = (uri, authToken) => new ReleaseClient(uri, new VssBasicCredential(string.Empty, authToken)); }
public RetryEventHandler(string eventName, IDictionary <string, string> eventProperties, CancellationToken cancellationToken, IBrokerInstrumentation brokerInstrumentation, HashSet <HttpStatusCode> transientStatusCodes = null) { this.eventName = eventName; this.eventProperties = eventProperties ?? new Dictionary <string, string>(); this.cancellationToken = cancellationToken; instrumentationHandler = brokerInstrumentation; if (transientStatusCodes != null) { this.trasientHttpCodes = transientStatusCodes; } }
public ServiceBusQueueMessageHandler(IServiceBusQueueMessageListener queueClient, IBrokerInstrumentation baseInstrumentation, IVstsScheduleHandler <T> scheduleHandler, ServiceBusQueueMessageHandlerSettings settings) { this.settings = settings; this.settings.LockRefreshDelayMsecs = settings.LockRefreshDelayMsecs == 0 ? 1 : settings.LockRefreshDelayMsecs; this.baseInstrumentation = baseInstrumentation; this.scheduleHandler = scheduleHandler; this.queueClient = queueClient; this.CreateTaskClient = TaskClientFactory.GetTaskClient; this.CreateBuildClient = (uri, authToken) => new BuildClient(uri, new VssBasicCredential(string.Empty, authToken)); this.CreateReleaseClient = (uri, authToken) => new ReleaseClient(uri, new VssBasicCredential(string.Empty, authToken)); this.CreateVstsReportingHelper = (vstsMessage, inst, props) => new VstsReportingHelper(vstsMessage, inst, props); }
public TaskClient(Uri baseUrl, VssCredentials credentials, IBrokerInstrumentation instrumentationHandler) : this(baseUrl, credentials, instrumentationHandler, DefaultRetryCount, DefaultRetryIntervalInSeconds) { }
public HandlerWithInstrumentation(IBrokerInstrumentation brokerInstrumentation, IVstsScheduleHandler <T> baseHandler) { this.brokerInstrumentation = brokerInstrumentation; this.baseHandler = baseHandler; }
private static async Task ProcessTestMessage(MockServiceBusMessage mockServiceBusMessage = null, MockServiceBusQueueMessageListener mockMessageListener = null, MockTaskClient mockTaskClient = null, MockVstsHandler handler = null, MockVstsReportingHelper mockReportingHelper = null, IBrokerInstrumentation instrumentation = null, int maxRetryAttempts = 1, IBuildClient mockBuildClient = null, IGitClient mockGitClient = null) { mockServiceBusMessage = mockServiceBusMessage ?? CreateMockMessage(CreateValidTestVstsMessage()); mockTaskClient = mockTaskClient ?? new MockTaskClient(); mockBuildClient = mockBuildClient ?? new MockBuildClient() { MockBuild = new Build() { Status = BuildStatus.InProgress } }; mockReportingHelper = mockReportingHelper ?? new MockVstsReportingHelper(new TestVstsMessage()); var mockReleaseClient = new MockReleaseClient() { MockRelease = new Release() { Status = ReleaseStatus.Active } }; handler = handler ?? new MockVstsHandler { MockExecuteFunc = (vstsMessage) => Task.FromResult(new VstsScheduleResult() { Message = "(test) mock execute requested", ScheduledId = "someId", ScheduleFailed = false }) }; instrumentation = instrumentation ?? new TraceBrokerInstrumentation(); var settings = new ServiceBusQueueMessageHandlerSettings { MaxRetryAttempts = maxRetryAttempts, TimeLineNamePrefix = "someTimeline", WorkerName = "someWorker" }; mockMessageListener = mockMessageListener ?? new MockServiceBusQueueMessageListener(); var schedulingBroker = new ServiceBusQueueMessageHandler <TestVstsMessage>(queueClient: mockMessageListener, baseInstrumentation: instrumentation, scheduleHandler: handler, settings: settings); schedulingBroker.CreateTaskClient = (uri, creds, instrumentationHandler, skipRaisePlanEvents) => mockTaskClient; schedulingBroker.CreateBuildClient = (uri, creds) => mockBuildClient; schedulingBroker.CreateReleaseClient = (uri, creds) => mockReleaseClient; schedulingBroker.CreateVstsReportingHelper = (vstsMessage, inst, props) => mockReportingHelper; var cancelSource = new CancellationTokenSource(); await schedulingBroker.ReceiveAsync(mockServiceBusMessage, cancelSource.Token); }
public TaskClientNoopPlanEvent(Uri baseUrl, VssCredentials credentials, IBrokerInstrumentation instrumentationHandler) : base(baseUrl, credentials, instrumentationHandler) { }