gosolo

package module
v0.0.0-...-e2c2bbc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound            = fmt.Errorf("not found")
	ErrMultipleFound       = fmt.Errorf("multiple found")
	ErrInvalidStreamEvent  = fmt.Errorf("invalid stream event")
	ErrInvalidStreamFormat = fmt.Errorf("invalid stream format")
)

Functions

func CreateName

func CreateName[T any](ctx context.Context, c *Client, name string, obj *T) (*T, error)

func DeleteName

func DeleteName[T any](ctx context.Context, c *Client, name, id string, opts *UpdateOpts[T]) error

func FindName

func FindName[T any](ctx context.Context, c *Client, name, shortID string) (*T, error)

func GetName

func GetName[T any](ctx context.Context, c *Client, name, id string, opts *GetOpts[T]) (*T, error)

func ListName

func ListName[T any](ctx context.Context, c *Client, name string, opts *ListOpts[T]) ([]*T, error)

func ReplaceName

func ReplaceName[T any](ctx context.Context, c *Client, name, id string, obj *T, opts *UpdateOpts[T]) (*T, error)

func UpdateName

func UpdateName[T any](ctx context.Context, c *Client, name, id string, obj *T, opts *UpdateOpts[T]) (*T, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, cfg *Config, getCreds GetUserPassFunc) (*Client, error)

func NewClientDirect

func NewClientDirect(baseURL string) *Client

func (*Client) CreateShardServerConfig

func (c *Client) CreateShardServerConfig(ctx context.Context, obj *ShardServerConfig) (*ShardServerConfig, error)

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, obj *Task) (*Task, error)

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, obj *Token) (*Token, error)

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, obj *User) (*User, error)

func (*Client) DebugInfo

func (c *Client) DebugInfo(ctx context.Context) (map[string]any, error)

func (*Client) DeleteShardServerConfig

func (c *Client) DeleteShardServerConfig(ctx context.Context, id string, opts *UpdateOpts[ShardServerConfig]) error

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, id string, opts *UpdateOpts[Task]) error

func (*Client) DeleteToken

func (c *Client) DeleteToken(ctx context.Context, id string, opts *UpdateOpts[Token]) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, id string, opts *UpdateOpts[User]) error

func (*Client) FindShardServerConfig

func (c *Client) FindShardServerConfig(ctx context.Context, shortID string) (*ShardServerConfig, error)

func (*Client) FindTask

func (c *Client) FindTask(ctx context.Context, shortID string) (*Task, error)

func (*Client) FindToken

func (c *Client) FindToken(ctx context.Context, shortID string) (*Token, error)

func (*Client) FindUser

func (c *Client) FindUser(ctx context.Context, shortID string) (*User, error)

func (*Client) GetShardServerConfig

func (c *Client) GetShardServerConfig(ctx context.Context, id string, opts *GetOpts[ShardServerConfig]) (*ShardServerConfig, error)

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id string, opts *GetOpts[Task]) (*Task, error)

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context, id string, opts *GetOpts[Token]) (*Token, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, id string, opts *GetOpts[User]) (*User, error)

func (*Client) GoClient

func (c *Client) GoClient(ctx context.Context) (string, error)

func (*Client) ListShardServerConfig

func (c *Client) ListShardServerConfig(ctx context.Context, opts *ListOpts[ShardServerConfig]) ([]*ShardServerConfig, error)

func (*Client) ListTask

func (c *Client) ListTask(ctx context.Context, opts *ListOpts[Task]) ([]*Task, error)

func (*Client) ListToken

func (c *Client) ListToken(ctx context.Context, opts *ListOpts[Token]) ([]*Token, error)

func (*Client) ListUser

func (c *Client) ListUser(ctx context.Context, opts *ListOpts[User]) ([]*User, error)

func (*Client) OpenAPI

func (c *Client) OpenAPI(ctx context.Context) (map[string]any, error)

func (*Client) ReplaceShardServerConfig

func (c *Client) ReplaceShardServerConfig(ctx context.Context, id string, obj *ShardServerConfig, opts *UpdateOpts[ShardServerConfig]) (*ShardServerConfig, error)

func (*Client) ReplaceTask

func (c *Client) ReplaceTask(ctx context.Context, id string, obj *Task, opts *UpdateOpts[Task]) (*Task, error)

func (*Client) ReplaceToken

func (c *Client) ReplaceToken(ctx context.Context, id string, obj *Token, opts *UpdateOpts[Token]) (*Token, error)

func (*Client) ReplaceUser

func (c *Client) ReplaceUser(ctx context.Context, id string, obj *User, opts *UpdateOpts[User]) (*User, error)

func (*Client) ResetAuth

func (c *Client) ResetAuth() *Client

func (*Client) SetAuthToken

func (c *Client) SetAuthToken(token string) *Client

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string) *Client

func (*Client) SetBasicAuth

func (c *Client) SetBasicAuth(user, pass string) *Client

func (*Client) SetCloseConnection

func (c *Client) SetCloseConnection(cl bool) *Client

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool) *Client

func (*Client) SetHeader

func (c *Client) SetHeader(name, value string) *Client

func (*Client) SetTLSClientConfig

func (c *Client) SetTLSClientConfig(cfg *tls.Config) *Client

func (*Client) StreamGetShardServerConfig

func (c *Client) StreamGetShardServerConfig(ctx context.Context, id string, opts *GetOpts[ShardServerConfig]) (*GetStream[ShardServerConfig], error)

func (*Client) StreamGetTask

func (c *Client) StreamGetTask(ctx context.Context, id string, opts *GetOpts[Task]) (*GetStream[Task], error)

func (*Client) StreamGetToken

func (c *Client) StreamGetToken(ctx context.Context, id string, opts *GetOpts[Token]) (*GetStream[Token], error)

func (*Client) StreamGetUser

func (c *Client) StreamGetUser(ctx context.Context, id string, opts *GetOpts[User]) (*GetStream[User], error)

func (*Client) StreamListShardServerConfig

func (c *Client) StreamListShardServerConfig(ctx context.Context, opts *ListOpts[ShardServerConfig]) (*ListStream[ShardServerConfig], error)

func (*Client) StreamListTask

func (c *Client) StreamListTask(ctx context.Context, opts *ListOpts[Task]) (*ListStream[Task], error)

func (*Client) StreamListToken

func (c *Client) StreamListToken(ctx context.Context, opts *ListOpts[Token]) (*ListStream[Token], error)

func (*Client) StreamListUser

func (c *Client) StreamListUser(ctx context.Context, opts *ListOpts[User]) (*ListStream[User], error)

func (*Client) TSClient

func (c *Client) TSClient(ctx context.Context) (string, error)

func (*Client) UpdateShardServerConfig

func (c *Client) UpdateShardServerConfig(ctx context.Context, id string, obj *ShardServerConfig, opts *UpdateOpts[ShardServerConfig]) (*ShardServerConfig, error)

func (*Client) UpdateTask

func (c *Client) UpdateTask(ctx context.Context, id string, obj *Task, opts *UpdateOpts[Task]) (*Task, error)

func (*Client) UpdateToken

func (c *Client) UpdateToken(ctx context.Context, id string, obj *Token, opts *UpdateOpts[Token]) (*Token, error)

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, id string, obj *User, opts *UpdateOpts[User]) (*User, error)

type Config

type Config struct {
	BaseURL string `json:"baseURL" toml:"baseURL"`
	Token   string `json:"token" toml:"token"`
	Shard   string `json:"shard" toml:"shard"`

	Debug    bool `json:"debug" toml:"debug"`
	Insecure bool `json:"insecure" toml:"insecure"`
}

type Filter

type Filter struct {
	Path  string
	Op    string
	Value string
}

type GetOpts

type GetOpts[T any] struct {
	Prev *T
}

type GetStream

type GetStream[T any] struct {
	// contains filtered or unexported fields
}

func StreamGetName

func StreamGetName[T any](ctx context.Context, c *Client, name, id string, opts *GetOpts[T]) (*GetStream[T], error)

func (*GetStream[T]) Chan

func (gs *GetStream[T]) Chan() <-chan *T

func (*GetStream[T]) Close

func (gs *GetStream[T]) Close()

func (*GetStream[T]) Error

func (gs *GetStream[T]) Error() error

func (*GetStream[T]) LastEventReceived

func (gs *GetStream[T]) LastEventReceived() time.Time

func (*GetStream[T]) Read

func (gs *GetStream[T]) Read() *T

type GetUserPassFunc

type GetUserPassFunc func() (string, string, error)

type ListOpts

type ListOpts[T any] struct {
	Stream  string
	Limit   int64
	Offset  int64
	After   string
	Sorts   []string
	Filters []Filter

	Prev []*T
}

type ListStream

type ListStream[T any] struct {
	// contains filtered or unexported fields
}

func StreamListName

func StreamListName[T any](ctx context.Context, c *Client, name string, opts *ListOpts[T]) (*ListStream[T], error)

func (*ListStream[T]) Chan

func (ls *ListStream[T]) Chan() <-chan []*T

func (*ListStream[T]) Close

func (ls *ListStream[T]) Close()

func (*ListStream[T]) Error

func (ls *ListStream[T]) Error() error

func (*ListStream[T]) LastEventReceived

func (ls *ListStream[T]) LastEventReceived() time.Time

func (*ListStream[T]) Read

func (ls *ListStream[T]) Read() []*T

type ShardServerConfig

type ShardServerConfig struct {
	metadata.Metadata

	ListETag   string `json:"-"`
	ShardID    string `json:"shardID,omitempty"`
	InstanceID string `json:"instanceID,omitempty"`
}

type Task

type Task struct {
	metadata.Metadata

	ListETag string    `json:"-"`
	UserID   string    `json:"userID,omitempty"`
	Name     string    `json:"name,omitempty"`
	Complete bool      `json:"complete,omitempty"`
	After    time.Time `json:"after,omitempty"`
}

type Token

type Token struct {
	metadata.Metadata

	ListETag string `json:"-"`
	UserID   string `json:"userID,omitempty"`
	Token    string `json:"token,omitempty"`
	Shard    string `json:"shard,omitempty"`
}

type UpdateOpts

type UpdateOpts[T any] struct {
	Prev *T
}

type User

type User struct {
	metadata.Metadata

	ListETag          string `json:"-"`
	Name              string `json:"name,omitempty"`
	Email             string `json:"email,omitempty"`
	Password          string `json:"password,omitempty"`
	Shard             string `json:"shard,omitempty"`
	ServiceAdmin      bool   `json:"serviceAdmin,omitempty"`
	ReplicationClient bool   `json:"replicationClient,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL