public virtual async ValueTask <IReadOnlyDictionary <Sha1, ReadOnlyMemory <byte> > > ReadObjectBatchAsync(IEnumerable <Sha1> objectIds, CancellationToken cancellationToken) { if (objectIds == null) { return(ReadOnlyDictionary.Empty <Sha1, ReadOnlyMemory <byte> >()); } var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = MaxDop, CancellationToken = cancellationToken }; // Enumerate batches var dict = new ConcurrentDictionary <Sha1, ReadOnlyMemory <byte> >(Sha1Comparer.Default); await ParallelAsync.ForEachAsync(objectIds, parallelOptions, async sha1 => { // Execute batch var buffer = await ReadObjectAsync(sha1, cancellationToken).ConfigureAwait(false); if (buffer.HasValue) { dict[sha1] = buffer.Value; } }).ConfigureAwait(false); return(dict); }
/// <summary> /// Creates a new instance of the <see cref="Path"/> class. /// </summary> /// <param name="summary">The string summary intended to apply to all operations in this path.</param> /// <param name="description">The string description intended to apply to all operations in this path.</param> /// <param name="get">The definition of a GET operation on this path.</param> /// <param name="put">The definition of a PUT operation on this path.</param> /// <param name="post">The definition of a POST operation on this path.</param> /// <param name="delete">The definition of a DELETE operation on this path.</param> /// <param name="options">The definition of a OPTIONS operation on this path.</param> /// <param name="head">The definition of a HEAD operation on this path.</param> /// <param name="patch">The definition of a PATCH operation on this path.</param> /// <param name="trace">The definition of a TRACE operation on this path.</param> /// <param name="servers">The alternative server list to service all operations in this path.</param> /// <param name="parameters">The list of parameters that are applicable for all the operations described under this path.</param> public Path( string summary = default, string description = default, Operation get = default, Operation put = default, Operation post = default, Operation delete = default, Operation options = default, Operation head = default, Operation patch = default, Operation trace = default, IReadOnlyList <Server> servers = default, IReadOnlyDictionary <ParameterKey, Referable <ParameterBody> > parameters = default) { Summary = summary; Description = description; Get = get; Put = put; Post = post; Delete = delete; Options = options; Head = head; Patch = patch; Trace = trace; Servers = servers ?? Array.Empty <Server>(); Parameters = parameters ?? ReadOnlyDictionary.Empty <ParameterKey, Referable <ParameterBody> >(); }
/// <summary> /// Creates a new instance of the <see cref="Operation"/> class. /// </summary> /// <param name="tags">The list of tags for API documentation control.</param> /// <param name="summary">The short summary of what the operation does.</param> /// <param name="description">The verbose explanation of the operation behavior.</param> /// <param name="externalDocumentation">The additional external documentation for this operation.</param> /// <param name="operationIdentifier">The unique string used to identify the operation.</param> /// <param name="parameters">The list of parameters that are applicable for this operation.</param> /// <param name="requestBody">The request body applicable for this operation.</param> /// <param name="responses">The list of possible responses as they are returned from executing this operation.</param> /// <param name="callbacks">The map of possible out-of band callbacks related to the parent operation.</param> /// <param name="options">The flags that indicate what options are set on the operation.</param> /// <param name="security">The declaration of which security mechanisms can be used for this operation.</param> /// <param name="servers">The alternative server list to service this operation.</param> public Operation( IReadOnlyList <string> tags = default, string summary = default, string description = default, ExternalDocumentation externalDocumentation = default, string operationIdentifier = default, IReadOnlyDictionary <ParameterKey, Referable <ParameterBody> > parameters = default, Referable <RequestBody> requestBody = default, IReadOnlyDictionary <ResponseKey, Referable <Response> > responses = default, IReadOnlyDictionary <string, Referable <Callback> > callbacks = default, OperationOptions options = default, IReadOnlyList <SecurityScheme> security = default, IReadOnlyList <Server> servers = default) { Tags = tags ?? Array.Empty <string>(); Summary = summary; Description = description; ExternalDocumentation = externalDocumentation; OperationIdentifier = operationIdentifier; Parameters = parameters ?? ReadOnlyDictionary.Empty <ParameterKey, Referable <ParameterBody> >(); RequestBody = requestBody; Responses = responses ?? ReadOnlyDictionary.Empty <ResponseKey, Referable <Response> >(); Callbacks = callbacks ?? ReadOnlyDictionary.Empty <string, Referable <Callback> >(); Options = options; Security = security ?? Array.Empty <SecurityScheme>(); Servers = servers ?? Array.Empty <Server>(); }
/// <summary> /// Creates a new instance of the <see cref="RequestBody"/> class. /// </summary> /// <param name="description">The brief description of the request body.</param> /// <param name="content">The content of the request body.</param> /// <param name="options">The request body options.</param> public RequestBody( string description = default, IReadOnlyDictionary <ContentType, MediaType> content = default, RequestBodyOptions options = default) { Description = description; Content = content ?? ReadOnlyDictionary.Empty <ContentType, MediaType>(); Options = options; }
/// <summary> /// Creates a new instance of the <see cref="MediaType"/> class. /// </summary> /// <param name="schema">The schema defining the type used for the request body.</param> /// <param name="examples">Gets the examples of the media type.</param> /// <param name="encoding">Gets the map between a property name and its encoding information.</param> public MediaType( Referable <Schema> schema = default, IReadOnlyDictionary <string, Referable <Example> > examples = default, IReadOnlyDictionary <string, PropertyEncoding> encoding = default) { Schema = schema; Examples = examples ?? ReadOnlyDictionary.Empty <string, Referable <Example> >(); Encoding = encoding ?? ReadOnlyDictionary.Empty <string, PropertyEncoding>(); }
/// <summary> /// Creates a new instance of the <see cref="Server"/> class. /// </summary> /// <param name="url">The URL to the target host.</param> /// <param name="description">The optional string describing the host designated by the URL.</param> /// <param name="variables">The map between a variable name and its value.</param> public Server( Uri url = default, string description = default, IReadOnlyDictionary <string, ServerVariable> variables = default) { Url = url; Description = description; Variables = variables ?? ReadOnlyDictionary.Empty <string, ServerVariable>(); }
/// <summary> /// Creates a new instance of the <see cref="OAuthFlow"/> class. /// </summary> /// <param name="authorizationUrl">The authorization URL to be used for this flow.</param> /// <param name="tokenUrl">The token URL to be used for this flow.</param> /// <param name="refreshUrl">The URL to be used for obtaining refresh tokens.</param> /// <param name="scopes">The available scopes for the OAuth2 security scheme.</param> public OAuthFlow( Uri authorizationUrl = default, Uri tokenUrl = default, Uri refreshUrl = default, IReadOnlyDictionary <string, string> scopes = default) { AuthorizationUrl = authorizationUrl; TokenUrl = tokenUrl; RefreshUrl = refreshUrl; Scopes = scopes ?? ReadOnlyDictionary.Empty <string, string>(); }
/// <summary> /// Creates a new instance of the <see cref="Response"/> class. /// </summary> /// <param name="description">Theshort description of the response.</param> /// <param name="headers">The map of headers to their definition.</param> /// <param name="content">The map containing descriptions of potential response payloads.</param> /// <param name="links">The map of operations links that can be followed from the response.</param> public Response( string description = default, IReadOnlyDictionary <string, Referable <ParameterBody> > headers = default, IReadOnlyDictionary <ContentType, MediaType> content = default, IReadOnlyDictionary <string, Referable <Link> > links = default) { Description = description; Headers = headers ?? ReadOnlyDictionary.Empty <string, Referable <ParameterBody> >(); Content = content ?? ReadOnlyDictionary.Empty <ContentType, MediaType>(); Links = links ?? ReadOnlyDictionary.Empty <string, Referable <Link> >(); }
/// <summary> /// Creates a new instance of the <see cref="PropertyEncoding"/> class. /// </summary> /// <param name="contentType">The Content-Type for encoding a specific property.</param> /// <param name="headers">The list of headers.</param> /// <param name="style"></param> /// <param name="options"></param> public PropertyEncoding( ContentType contentType = default, IReadOnlyDictionary <string, Referable <ParameterBody> > headers = default, ParameterStyle style = default, PropertyEncodingOptions options = default) { ContentType = contentType; Headers = headers ?? ReadOnlyDictionary.Empty <string, Referable <ParameterBody> >(); Style = style; Options = options; }
/// <summary> /// Creates a new instance of the <see cref="ParameterBody"/> class. /// </summary> /// <param name="description">The brief description of the parameter.</param> /// <param name="options">The parameter options.</param> /// <param name="style">The value which indicates how the parameter value will be serialized depending on the type of the parameter value.</param> /// <param name="schema">The schema defining the type used for the parameter.</param> /// <param name="examples">The list of examples of the parameter.</param> /// <param name="content">The map containing the representations for the parameter.</param> public ParameterBody( string description = default, ParameterOptions options = default, ParameterStyle style = default, Referable <Schema> schema = default, IReadOnlyDictionary <ContentType, Referable <Example> > examples = default, IReadOnlyDictionary <ContentType, MediaType> content = default) { Description = description; Options = options; Style = style; Schema = schema; Examples = examples ?? ReadOnlyDictionary.Empty <ContentType, Referable <Example> >(); Content = content ?? ReadOnlyDictionary.Empty <ContentType, MediaType>(); }
/// <summary> /// Creates a new instance of the <see cref="Document"/> class. /// </summary> /// <param name="version">The semantic version number of the OpenAPI Specification version that the OpenAPI document uses. The default is 3.0.0.</param> /// <param name="info">The metadata about the API.</param> /// <param name="servers">The list of <see cref="Server"/> instances, which provide connectivity information to a target server.</param> /// <param name="paths">The available paths and operations for the API.</param> /// <param name="components">The list that holds various schemas for the specification.</param> /// <param name="security">The declaration of which security mechanisms can be used across the API.</param> /// <param name="tags">The list of tags used by the specification with additional metadata.</param> /// <param name="externalDocumentation">The external documentation.</param> public Document( SemanticVersion?version = default, Information info = default, IReadOnlyList <Server> servers = default, IReadOnlyDictionary <string, Referable <Path> > paths = default, Components components = default, IReadOnlyList <Referable <SecurityScheme> > security = default, IReadOnlyList <Tag> tags = default, ExternalDocumentation externalDocumentation = default) { Version = version ?? new SemanticVersion(3, 0, 0); Info = info; Servers = servers ?? Array.Empty <Server>(); Paths = paths ?? ReadOnlyDictionary.Empty <string, Referable <Path> >(); Components = components; Security = security ?? Array.Empty <Referable <SecurityScheme> >(); Tags = tags ?? Array.Empty <Tag>(); ExternalDocumentation = externalDocumentation; }
public override async ValueTask <IReadOnlyDictionary <TreeId, TreeNodeMap> > ReadTreeBatchAsync(IEnumerable <TreeId> treeIds, CancellationToken cancellationToken) { if (treeIds == null) { return(ReadOnlyDictionary.Empty <TreeId, TreeNodeMap>()); } // TODO: Enable piecemeal reads (404s incur next repo) // We read from closest to furthest var trees = treeIds.ToArray(); for (var i = 0; i < Chain.Length; i++) { var dict = await Chain[i].ReadTreeBatchAsync(trees, cancellationToken).ConfigureAwait(false); if (dict.Count == trees.Length) { return(dict); } } // NotFound return(default);
public override ValueTask <IReadOnlyDictionary <Sha1, ReadOnlyMemory <byte> > > ReadObjectBatchAsync(IEnumerable <Sha1> objectIds, ParallelOptions parallelOptions) { if (objectIds == null) { return(new ValueTask <IReadOnlyDictionary <Sha1, ReadOnlyMemory <byte> > >(ReadOnlyDictionary.Empty <Sha1, ReadOnlyMemory <byte> >())); } // Execute batches var task = ParallelAsync.ForEachAsync(objectIds, parallelOptions, async n => { // Execute batch var buffer = await ReadObjectAsync(n, parallelOptions.CancellationToken).ConfigureAwait(false); // Transform batch result var kvp = new KeyValuePair <Sha1, ReadOnlyMemory <byte> >(n, buffer); return(kvp); }); return(task); }
public static void ReadOnlyDictionary_Empty() { var empty = ReadOnlyDictionary.Empty <string, int>(); Assert.Equal(0, empty.Count); }
public void Empty() { ReadOnlyDictionary.Empty <int, int>().AssertDictionaryEquals(new Dictionary <int, int>()); }