WeaviateEx.Config.Proxy (WeaviateEx v0.7.4)
View SourceProxy configuration for HTTP, HTTPS, and gRPC connections.
This module provides proxy support for Weaviate client connections, reading from environment variables or explicit configuration.
Environment Variables
The following environment variables are read (case-insensitive):
HTTP_PROXY/http_proxy- HTTP proxy URLHTTPS_PROXY/https_proxy- HTTPS proxy URLGRPC_PROXY/grpc_proxy- gRPC proxy URL
Uppercase variables take precedence over lowercase.
Examples
# From environment variables
proxy = Proxy.from_env()
# Explicit configuration
proxy = Proxy.new(
http: "http://proxy.example.com:8080",
https: "https://proxy.example.com:8443",
grpc: "grpc://proxy.example.com:50051"
)
# Check if proxy is configured
Proxy.configured?(proxy)
# => true
# Get proxy for a specific URL
Proxy.http_proxy_for(proxy, "https://weaviate.example.com")
# => "https://proxy.example.com:8443"
# Get Finch HTTP client options
Proxy.to_finch_opts(proxy)
# => [proxy: {:https, "proxy.example.com", 8443, []}]
# Get gRPC channel options
Proxy.to_grpc_opts(proxy)
# => [http_proxy: "grpc://proxy.example.com:50051"]
Summary
Functions
Check if any proxy is configured.
Create proxy configuration from environment variables.
Get the appropriate HTTP proxy for a given URL.
Create a new proxy configuration from explicit options.
Convert proxy configuration to Finch HTTP client options.
Convert proxy configuration to gRPC channel options.
Types
Functions
Check if any proxy is configured.
Examples
proxy = Proxy.new()
Proxy.configured?(proxy)
# => false
proxy = Proxy.new(http: "http://proxy:8080")
Proxy.configured?(proxy)
# => true
@spec from_env() :: t()
Create proxy configuration from environment variables.
Reads from the following environment variables (case-insensitive):
HTTP_PROXY/http_proxyHTTPS_PROXY/https_proxyGRPC_PROXY/grpc_proxy
Uppercase variables take precedence over lowercase.
Examples
# With HTTP_PROXY=http://proxy:8080 set
proxy = Proxy.from_env()
proxy.http
# => "http://proxy:8080"
Get the appropriate HTTP proxy for a given URL.
Returns the HTTPS proxy for https:// URLs and HTTP proxy for http:// URLs. Falls back to HTTP proxy if HTTPS proxy is not configured.
Examples
proxy = Proxy.new(http: "http://proxy:8080", https: "https://proxy:8443")
Proxy.http_proxy_for(proxy, "http://api.example.com")
# => "http://proxy:8080"
Proxy.http_proxy_for(proxy, "https://api.example.com")
# => "https://proxy:8443"
Create a new proxy configuration from explicit options.
Options
:http- HTTP proxy URL (e.g., "http://proxy:8080"):https- HTTPS proxy URL (e.g., "https://proxy:8443"):grpc- gRPC proxy URL (e.g., "http://proxy:8080")
Examples
Proxy.new(
http: "http://proxy.example.com:8080",
https: "https://proxy.example.com:8443"
)
Convert proxy configuration to Finch HTTP client options.
Returns options suitable for passing to Finch.build/3.
Examples
proxy = Proxy.new(https: "https://proxy.example.com:8443")
Proxy.to_finch_opts(proxy)
# => [proxy: {:https, "proxy.example.com", 8443, []}]
Convert proxy configuration to gRPC channel options.
Returns options suitable for passing to GRPC.Stub.connect/2.
Examples
proxy = Proxy.new(grpc: "http://grpc-proxy.example.com:8080")
Proxy.to_grpc_opts(proxy)
# => [http_proxy: "http://grpc-proxy.example.com:8080"]