/// <inheritdoc /> public override BigQueryRoutine GetRoutine(RoutineReference routineReference, GetRoutineOptions options = null) { var request = CreateGetRoutineRequest(routineReference, options); var resource = request.Execute(); return(new BigQueryRoutine(this, resource)); }
/// <inheritdoc /> public async override Task <BigQueryRoutine> CreateRoutineAsync(RoutineReference routineReference, Routine resource, CreateRoutineOptions options = null, CancellationToken cancellationToken = default) { var request = CreateInsertRoutineRequest(routineReference, resource, options); var result = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false); return(new BigQueryRoutine(this, result)); }
/// <inheritdoc /> public override BigQueryRoutine CreateRoutine(RoutineReference routineReference, Routine resource, CreateRoutineOptions options = null) { var request = CreateInsertRoutineRequest(routineReference, resource, options); var result = request.Execute(); return(new BigQueryRoutine(this, result)); }
public void ReferenceSameAs_SecondNull() { RoutineReference first = new RoutineReference(); RoutineReference second = null; Assert.Throws <ArgumentNullException>(() => first.ReferencesSameAs(second)); }
private DeleteRequest CreateDeleteRoutineRequest(RoutineReference routineReference, DeleteRoutineOptions options) { GaxPreconditions.CheckNotNull(routineReference, nameof(routineReference)); var request = Service.Routines.Delete(routineReference.ProjectId, routineReference.DatasetId, routineReference.RoutineId); options?.ModifyRequest(request); return(request); }
private UpdateRequest CreateUpdateRoutineRequest(RoutineReference routineReference, Routine resource, UpdateRoutineOptions options) { CheckResourceReference(routineReference, resource); var request = Service.Routines.Update(resource, routineReference.ProjectId, routineReference.DatasetId, routineReference.RoutineId); options?.ModifyRequest(request); RetryIfETagPresent(request, resource); return(request); }
private static void CheckResourceReference(RoutineReference routineReference, Routine resource) { GaxPreconditions.CheckNotNull(routineReference, nameof(routineReference)); GaxPreconditions.CheckNotNull(resource, nameof(resource)); GaxPreconditions.CheckArgument( resource.RoutineReference == null || routineReference.ReferencesSameAs(resource.RoutineReference), nameof(resource.RoutineReference), $"If {nameof(resource.RoutineReference)} is specified, it must be the same as {nameof(routineReference)}"); }
private GetRequest CreateGetRoutineRequest(RoutineReference routineReference, GetRoutineOptions options) { GaxPreconditions.CheckNotNull(routineReference, nameof(routineReference)); var request = Service.Routines.Get(routineReference.ProjectId, routineReference.DatasetId, routineReference.RoutineId); options?.ModifyRequest(request); RetryHandler.MarkAsRetriable(request); return(request); }
public void ReferenceSameAs_False(string projectId, string datasetId, string routineId) { RoutineReference first = new RoutineReference { ProjectId = "project", DatasetId = "dataset", RoutineId = "routine" }; RoutineReference second = new RoutineReference { ProjectId = projectId, DatasetId = datasetId, RoutineId = routineId }; Assert.False(first.ReferencesSameAs(second)); }
private InsertRequest CreateInsertRoutineRequest(RoutineReference routineReference, Routine resource, CreateRoutineOptions options) { CheckResourceReference(routineReference, resource); resource.RoutineReference ??= routineReference; var request = Service.Routines.Insert(resource, routineReference.ProjectId, routineReference.DatasetId); options?.ModifyRequest(request); return(request); }
public void ReferenceSameAs_True() { RoutineReference first = new RoutineReference { ProjectId = "project", DatasetId = "dataset", RoutineId = "routine" }; RoutineReference second = new RoutineReference { ProjectId = "project", DatasetId = "dataset", RoutineId = "routine" }; Assert.True(first.ReferencesSameAs(second)); }
/// <inheritdoc /> public async override Task <BigQueryRoutine> GetOrCreateRoutineAsync(RoutineReference routineReference, Routine resource, GetRoutineOptions getOptions = null, CreateRoutineOptions createOptions = null, CancellationToken cancellationToken = default) { CheckResourceReference(routineReference, resource); try { return(await GetRoutineAsync(routineReference, getOptions, cancellationToken).ConfigureAwait(false)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { return(await CreateRoutineAsync(routineReference, resource, createOptions, cancellationToken).ConfigureAwait(false)); } }
/// <inheritdoc /> public override BigQueryRoutine GetOrCreateRoutine(RoutineReference routineReference, Routine resource, GetRoutineOptions getOptions = null, CreateRoutineOptions createOptions = null) { CheckResourceReference(routineReference, resource); try { return(GetRoutine(routineReference, getOptions)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { return(CreateRoutine(routineReference, resource, createOptions)); } }
public Task Execute <TParameters>(IProxy proxy, MethodInfo methodInfo, ref TParameters parameters) where TParameters : IValueContainer { var serviceProxyContext = (ServiceProxyContext)proxy.Context; var intent = new ExecuteRoutineIntent { Id = _numericIdGenerator.NewId(), ServiceId = serviceProxyContext.Descriptor.Id, MethodId = _routineMethodIdProvider.GetId(methodInfo), Parameters = parameters }; var taskResultType = // Dispose() does not return a task, and is the only exception. #warning check if it's really IDisposable.Dispose methodInfo.ReturnType == typeof(void) ? TaskAccessor.VoidTaskResultType : TaskAccessor.GetTaskResultType(methodInfo.ReturnType); var taskState = new RoutineReference { IntentId = intent.Id #warning must have id of actual routine for dynamic subscription (subscribe after a routine already scheduled). }; var proxyTask = TaskAccessor.CreateTask(taskState, taskResultType); bool executeInline = !_transitionScope.IsActive || !IsCalledByRoutine( _transitionScope.CurrentMonitor.Context, // Skip 2 stack frames: current method and dynamically-generated proxy. // WARNING! DO NOT PUT 'new StackFrame()' into a helper method! new StackFrame(skipFrames: 2, fNeedFileInfo: false)); if (executeInline) { ExecuteAndAwaitInBackground(intent, proxyTask); } else { _transitionScope.CurrentMonitor.RegisterIntent(intent, proxyTask); } return(proxyTask); }
public Task Execute <TParameters>(IProxy proxy, MethodInfo methodInfo, ref TParameters parameters) where TParameters : IValueContainer { var serviceProxyContext = (ServiceProxyContext)proxy.Context; var intent = new ExecuteRoutineIntent { Id = _numericIdGenerator.NewId(), ServiceId = serviceProxyContext.Service.Id, MethodId = _routineMethodIdProvider.GetId(methodInfo), Parameters = parameters }; var taskResultType = // Dispose() does not return a task, and is the only exception. #warning check if it's really IDisposable.Dispose methodInfo.ReturnType == typeof(void) ? TaskAccessor.VoidTaskResultType : TaskAccessor.GetTaskResultType(methodInfo.ReturnType); var taskState = new RoutineReference { IntentId = intent.Id #warning must have id of actual routine for dynamic subscription (subscribe after a routine already scheduled). }; var proxyTask = TaskAccessor.CreateTask(taskState, taskResultType); if (_transitionScope.IsActive) { _transitionScope.CurrentMonitor.RegisterIntent(intent, proxyTask); } else { ExecuteAndAwaitInBackground(intent, proxyTask); } return(proxyTask); }
/// <summary> /// Attempts to fetch the specified routine, creating it if it doesn't exist. /// </summary> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="resource">The routine resource representation to use for the creation. Must not be null. If this routine's <see cref="Routine.RoutineReference"/> is specified, then it must be the same as the one obtained from the other parameters, else it will be set to the one obtained from the other parameters.</param> /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param> /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param> /// <returns>The existing or new routine.</returns> public virtual BigQueryRoutine GetOrCreateRoutine(RoutineReference routineReference, Routine resource, GetRoutineOptions getOptions = null, CreateRoutineOptions createOptions = null) => throw new NotImplementedException();
/// <summary> /// Updates the specified routine to match the specified resource. /// </summary> /// <remarks> /// If the resource contains an ETag, it is used for optimistic concurrency validation. /// </remarks> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="resource">The routine resource representation to use for the update. All updatable fields will be updated. If this routine's <see cref="Routine.RoutineReference"/> is specified, then it must be the same as the one obtained from the other parameters, else it will be set to the one obtained from the other parameters.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <returns>The updated routine.</returns> public virtual BigQueryRoutine UpdateRoutine(RoutineReference routineReference, Routine resource, UpdateRoutineOptions options = null) => throw new NotImplementedException();
/// <summary> /// Deletes the specified routine. /// </summary> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> public virtual void DeleteRoutine(RoutineReference routineReference, DeleteRoutineOptions options = null) => throw new NotImplementedException();
/// <summary> /// Asynchronously deletes the specified routine. /// </summary> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation.</returns> public virtual Task DeleteRoutineAsync(RoutineReference routineReference, DeleteRoutineOptions options = null, CancellationToken cancellationToken = default) => throw new NotImplementedException();
/// <summary> /// Asynchronously retrieves the specified routine. /// </summary> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns>A task representing the asynchronous operation. When complete, the result is /// the requested routine.</returns> public virtual Task <BigQueryRoutine> GetRoutineAsync(RoutineReference routineReference, GetRoutineOptions options = null, CancellationToken cancellationToken = default) => throw new NotImplementedException();
/// <inheritdoc /> public override void DeleteRoutine(RoutineReference routineReference, DeleteRoutineOptions options = null) { var request = CreateDeleteRoutineRequest(routineReference, options); request.Execute(); }
/// <inheritdoc /> public async override Task DeleteRoutineAsync(RoutineReference routineReference, DeleteRoutineOptions options = null, CancellationToken cancellationToken = default) { var request = CreateDeleteRoutineRequest(routineReference, options); await request.ExecuteAsync(cancellationToken).ConfigureAwait(false); }
/// <summary> /// Retrieves the specified routine. /// </summary> /// <param name="routineReference">A fully-qualified identifier for the routine. Must not be null.</param> /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param> /// <returns>The requested routine.</returns> public virtual BigQueryRoutine GetRoutine(RoutineReference routineReference, GetRoutineOptions options = null) => throw new NotImplementedException();
public Task Execute <TParameters>(IProxy proxy, MethodInfo methodInfo, ref TParameters parameters) where TParameters : IValueContainer { var serviceProxyContext = (ServiceProxyContext)proxy.Context; var methodDefinition = serviceProxyContext.Definition.FindMethod(methodInfo); if (methodDefinition == null || methodDefinition.IsIgnored) { var invoker = _methodInvokerFactory.Create(methodInfo); return(invoker.Invoke(proxy, parameters)); } var intent = new ExecuteRoutineIntent { Id = _idGenerator.NewId(), Service = serviceProxyContext.Descriptor.Id, Method = _routineMethodIdProvider.GetId(methodInfo), Parameters = parameters }; Type taskResultType = methodInfo.ReturnType == typeof(void) ? TaskAccessor.VoidTaskResultType : TaskAccessor.GetTaskResultType(methodInfo.ReturnType); var taskState = new RoutineReference { ServiceId = intent.Service, MethodId = intent.Method, IntentId = intent.Id #warning must have id of actual routine for dynamic subscription (subscribe after a routine already scheduled). }; var proxyTask = TaskAccessor.CreateTask(taskState, taskResultType); bool invokedByRunningMethod = _transitionScope.IsActive && IsCalledByRoutine( _transitionScope.CurrentMonitor.Context, // Skip 2 stack frames: current method and dynamically-generated proxy. // WARNING! DO NOT PUT 'new StackFrame()' into a helper method! new StackFrame(skipFrames: 2, fNeedFileInfo: false)); bool ignoreTransaction = !invokedByRunningMethod; if (!ignoreTransaction && _transitionScope.IsActive) { var runningMethodSettings = _communicationSettingsProvider.GetMethodSettings( _transitionScope.CurrentMonitor.Context.MethodRef.Definition); if (!runningMethodSettings.Transactional) { ignoreTransaction = true; } } if (!ignoreTransaction) { var methodSettings = _communicationSettingsProvider.GetMethodSettings(methodDefinition); if (methodSettings.IgnoreTransaction) { ignoreTransaction = true; } } if (ignoreTransaction) { ExecuteAndAwaitInBackground(intent, proxyTask); } else { _transitionScope.CurrentMonitor.RegisterIntent(intent, proxyTask); } return(proxyTask); }