Documentation
¶
Overview ¶
Package seaweed provides Go clients for SeaweedFS native HTTP APIs and the SeaweedFS S3/IAM compatibility endpoints.
The root Client composes service clients for master, volume, blob, filer, TUS, S3, and IAM. Use the root client when one process talks to several SeaweedFS services with shared HTTP, retry, authentication, and endpoint policy settings. Direct subpackage clients are available when only one SeaweedFS service is needed.
Index ¶
- Constants
- func NewHTTPClient(config HTTPClientConfig) *http.Client
- type APIError
- type Client
- func (c *Client) Blob() *blob.Client
- func (c *Client) Close()
- func (c *Client) Config() Config
- func (c *Client) Filer() *filer.Client
- func (c *Client) IAM(ctx context.Context) (*iam.Client, error)
- func (c *Client) Master() *master.Client
- func (c *Client) S3(ctx context.Context) (*s3.Client, error)
- func (c *Client) TUS() *tus.Client
- func (c *Client) Volume() *volume.Client
- type Config
- type EndpointCircuitBreakerPolicy
- type EndpointHealthCheckPolicy
- type EndpointPolicy
- type EndpointPolicyMode
- type Error
- type HTTPClientConfig
- type Option
- type RetryPolicy
Examples ¶
Constants ¶
const ( // EndpointPolicyFailover keeps using the active endpoint until it fails. EndpointPolicyFailover = httpx.EndpointPolicyFailover // EndpointPolicyRoundRobin rotates the starting endpoint for retryable requests. EndpointPolicyRoundRobin = httpx.EndpointPolicyRoundRobin )
Variables ¶
This section is empty.
Functions ¶
func NewHTTPClient ¶
func NewHTTPClient(config HTTPClientConfig) *http.Client
NewHTTPClient builds an HTTP client tuned for SeaweedFS SDK workloads.
Example ¶
package main
import (
"fmt"
"github.com/lingjhf/seaweed"
)
func main() {
httpClient := seaweed.NewHTTPClient(seaweed.HTTPClientConfig{
MaxIdleConnsPerHost: 64,
})
client, err := seaweed.New(seaweed.Config{
MasterURLs: []string{"http://127.0.0.1:9333"},
}, seaweed.WithHTTPClient(httpClient))
if err != nil {
panic(err)
}
defer client.Close()
fmt.Println(client.Config().MasterURLs[0])
}
Output: http://127.0.0.1:9333
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a root SeaweedFS client that owns shared transport and service clients.
func New ¶
New creates a root SeaweedFS client from config.
Example ¶
package main
import (
"fmt"
"github.com/lingjhf/seaweed"
)
func main() {
client, err := seaweed.New(seaweed.Config{
MasterURLs: []string{"http://127.0.0.1:9333"},
FilerURLs: []string{"http://127.0.0.1:8888"},
TUSBasePath: "/.tus",
})
if err != nil {
panic(err)
}
fmt.Println(client.Config().TUSBasePath)
}
Output: /.tus
func (*Client) Close ¶
func (c *Client) Close()
Close stops background endpoint health checks and releases cached clients.
type Config ¶
type Config struct {
// MasterURLs are the SeaweedFS master HTTP endpoints. At least one is required.
MasterURLs []string
// VolumeURLs are optional direct volume server HTTP endpoints.
VolumeURLs []string
// FilerURLs are optional filer HTTP endpoints used by the filer and TUS clients.
FilerURLs []string
// TUSBasePath is the filer TUS base path. The default is "/.tus".
TUSBasePath string
// S3URLs are optional SeaweedFS S3 gateway endpoints.
S3URLs []string
// IAMURLs are optional SeaweedFS IAM endpoints. When empty, IAM uses S3URLs.
IAMURLs []string
// Region is the AWS signing region for S3 and IAM clients. The default is "us-east-1".
Region string
// AccessKeyID is the S3/IAM access key.
AccessKeyID string
// SecretAccessKey is the S3/IAM secret key.
SecretAccessKey string
// BearerToken is sent as an Authorization bearer token on native HTTP APIs.
BearerToken string
// UserAgent overrides the User-Agent sent by native HTTP API clients.
UserAgent string
// UsePublicURLs makes the blob client prefer public volume URLs returned by master.
UsePublicURLs bool
// Retry controls retries for retryable native HTTP API methods.
Retry RetryPolicy
// BlobLocationCacheTTL limits how long blob volume lookups are cached.
BlobLocationCacheTTL time.Duration
// EnableVolumeAuthorization makes Blob use master-issued per-file
// Authorization headers for volume reads, writes, and deletes.
EnableVolumeAuthorization bool
// EndpointPolicy is the default policy for all endpoint lists.
EndpointPolicy EndpointPolicy
// MasterEndpointPolicy overrides EndpointPolicy for the master client.
MasterEndpointPolicy EndpointPolicy
// VolumeEndpointPolicy overrides EndpointPolicy for the direct volume client.
VolumeEndpointPolicy EndpointPolicy
// BlobEndpointPolicy overrides EndpointPolicy for blob volume reads.
BlobEndpointPolicy EndpointPolicy
// FilerEndpointPolicy overrides EndpointPolicy for the filer client.
FilerEndpointPolicy EndpointPolicy
// TUSEndpointPolicy overrides EndpointPolicy for the TUS client.
TUSEndpointPolicy EndpointPolicy
// S3EndpointPolicy overrides EndpointPolicy for the S3 client.
S3EndpointPolicy EndpointPolicy
// IAMEndpointPolicy overrides EndpointPolicy for the IAM client.
IAMEndpointPolicy EndpointPolicy
}
Config configures a root SeaweedFS client.
Example (EndpointPolicy) ¶
package main
import (
"fmt"
"github.com/lingjhf/seaweed"
)
func main() {
config := seaweed.Config{
MasterURLs: []string{
"http://master-1:9333",
"http://master-2:9333",
},
EndpointPolicy: seaweed.EndpointPolicy{
Mode: seaweed.EndpointPolicyRoundRobin,
CircuitBreaker: seaweed.EndpointCircuitBreakerPolicy{
Enabled: true,
FailureThreshold: 2,
},
},
}
fmt.Println(config.EndpointPolicy.Mode)
fmt.Println(config.EndpointPolicy.CircuitBreaker.FailureThreshold)
}
Output: round-robin 2
type EndpointCircuitBreakerPolicy ¶
type EndpointCircuitBreakerPolicy = httpx.EndpointCircuitBreakerPolicy
EndpointCircuitBreakerPolicy configures endpoint failure isolation.
type EndpointHealthCheckPolicy ¶
type EndpointHealthCheckPolicy = httpx.EndpointHealthCheckPolicy
EndpointHealthCheckPolicy configures background endpoint health probes.
type EndpointPolicy ¶
type EndpointPolicy = httpx.EndpointPolicy
EndpointPolicy controls how clients choose among multiple service endpoints.
func DefaultEndpointPolicy ¶
func DefaultEndpointPolicy() EndpointPolicy
DefaultEndpointPolicy returns the default failover endpoint policy.
type EndpointPolicyMode ¶
type EndpointPolicyMode = httpx.EndpointPolicyMode
EndpointPolicyMode selects the endpoint selection strategy.
type HTTPClientConfig ¶
type HTTPClientConfig struct {
MaxIdleConns int
MaxIdleConnsPerHost int
IdleConnTimeout time.Duration
DialTimeout time.Duration
KeepAlive time.Duration
TLSHandshakeTimeout time.Duration
ExpectContinueTimeout time.Duration
ResponseHeaderTimeout time.Duration
Timeout time.Duration
}
HTTPClientConfig configures the HTTP client created by NewHTTPClient.
func DefaultHTTPClientConfig ¶
func DefaultHTTPClientConfig() HTTPClientConfig
DefaultHTTPClientConfig returns the default transport settings for NewHTTPClient.
type Option ¶
type Option func(*options)
Option customizes root client construction.
func WithHTTPClient ¶
WithHTTPClient makes New use client for all native and AWS SDK requests.
type RetryPolicy ¶
type RetryPolicy = httpx.RetryPolicy
RetryPolicy controls retry attempts for retryable HTTP methods.
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns the default retry policy used by New.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package blob provides file ID based upload, read, head, and delete helpers.
|
Package blob provides file ID based upload, read, head, and delete helpers. |
|
examples
|
|
|
basic
command
|
|
|
s3
command
|
|
|
Package filer provides a path-based client for SeaweedFS filer HTTP APIs.
|
Package filer provides a path-based client for SeaweedFS filer HTTP APIs. |
|
internal
|
|
|
httpx
Package httpx contains shared HTTP transport, retry, error, and endpoint policy helpers for SeaweedFS SDK clients.
|
Package httpx contains shared HTTP transport, retry, error, and endpoint policy helpers for SeaweedFS SDK clients. |
|
Package master provides a client for SeaweedFS master HTTP APIs.
|
Package master provides a client for SeaweedFS master HTTP APIs. |
|
Package tus provides a client for SeaweedFS TUS resumable upload support.
|
Package tus provides a client for SeaweedFS TUS resumable upload support. |
|
Package volume provides a client for direct SeaweedFS volume server HTTP APIs.
|
Package volume provides a client for direct SeaweedFS volume server HTTP APIs. |