You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.go 742 B

7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package api
  2. import (
  3. "gitlink.org.cn/cloudream/common/sdks"
  4. )
  5. type response[T any] struct {
  6. Code string `json:"code"`
  7. Message string `json:"message"`
  8. Data T `json:"data"`
  9. }
  10. func (r *response[T]) ToError() *sdks.CodeMessageError {
  11. return &sdks.CodeMessageError{
  12. Code: r.Code,
  13. Message: r.Message,
  14. }
  15. }
  16. type Client struct {
  17. cfg *Config
  18. }
  19. func NewClient(cfg *Config) *Client {
  20. return &Client{
  21. cfg: cfg,
  22. }
  23. }
  24. type Pool interface {
  25. Acquire() (*Client, error)
  26. Release(cli *Client)
  27. }
  28. type pool struct {
  29. cfg *Config
  30. }
  31. func NewPool(cfg *Config) Pool {
  32. return &pool{
  33. cfg: cfg,
  34. }
  35. }
  36. func (p *pool) Acquire() (*Client, error) {
  37. cli := NewClient(p.cfg)
  38. return cli, nil
  39. }
  40. func (p *pool) Release(cli *Client) {
  41. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。