Skip to content

How about endpoint as URL in S3Settings? #9

Description

@dundich

EndPoint - воспринимается скорее как url, и путает когда ему ставят в значения host (localhost)

Минусы

  • breakchanges

Плюсы

  • Компактней настройки (минус: port, schema)
  • Ближе к настройкам Minio и Azure cloud

стало

public sealed class S3Settings
{
	public required string AccessKey { get; init; }

	public required string Bucket { get; init; } 
        
        // "http://{Hostname}:{Port)}
	public required string Endpoint { get; init; }

	public string Region { get; init; } = "us-east-1";

	public required string SecretKey { get; init; }

	public string Service { get; init; } = "s3";

	public bool UseHttp2 { get; init; }
}

c-tor S3Client фрагмент

       // Клиента сделать обязательным  и в тестах передавать из Fixture
	public S3Client(HttpClient client, S3Settings settings,  IArrayPool? arrayProvider = null)
	{
		Bucket = settings.Bucket ?? throw new ArgumentException(nameof(settings.Bucket));

		var endpoint = new Uri(settings.Endpoint);

		_bucket = $"{endpoint.AbsoluteUri}{Bucket.ToLowerInvariant()}";
		_client = client;
		_host = $"{endpoint.Host}:{endpoint.Port}";
		_useHttp2 = settings.UseHttp2;

		ArrayPool = arrayProvider ?? DefaultArrayPool.Instance;
		_httpDescription = new HttpDescription(
			ArrayPool,
			settings.AccessKey,
			settings.Region,
			settings.Service,
			S3Headers);
		_signature = new Signature(_httpDescription, settings.SecretKey, settings.Region, settings.Service);
	}

Зы. Ну или может стоит переименовать Endpoint в Host? тут мои капризы и если чо - можно закрыть..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions