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 809 B

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

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