client

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 11 Imported by: 0

README

url_shortener_client

client for URL shortener client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opts ...Opts) *Client

func (*Client) CheckHealth

func (c *Client) CheckHealth() (bool, error)

func (*Client) SetPoolCount

func (c *Client) SetPoolCount(count int)

func (*Client) ShortenURL

func (c *Client) ShortenURL(request ShortenURLRequest) (*URLCollection, error)

type FuncType

type FuncType string
const (
	ShortenURL  FuncType = "shorten_url"
	HealthCheck FuncType = "health_check"
)

type Opts

type Opts interface {
	Apply(*Client)
}

func WithBaseURL

func WithBaseURL(url string) Opts

func WithPoolCount

func WithPoolCount(count int) Opts

type ShortenURLRequest

type ShortenURLRequest struct {
	URL     string  `json:"url" example:"http://localhost:8080/test?test=test" description:"url to shorten"`
	EventID *string `json:"event_id" example:"5f9e9b9b9b9b9b9b9b9b9b98" description:"event id"`
	UserID  *string `json:"user_id" example:"5f9e9b9b9b9b9b9b9b9b9b9b" description:"user id"`
}

type URLCollection

type URLCollection struct {
	ID        primitive.ObjectID `json:"id" bson:"id" example:"5f9e9b9b9b9b9b9b9b9b9b9b" description:"id"`
	Host      string             `json:"host" bson:"host" example:"http://localhost:8080/" description:"host url"`
	Path      string             `json:"url" bson:"url" example:"/test" description:"url path"`
	Params    map[string]string  `json:"params" bson:"params" example:"{\"test\": \"test\"}" description:"query params"`
	Code      string             `json:"code" bson:"code" example:"3432" description:"short url code"` // indexed
	Count     int64              `json:"count" bson:"count" example:"3" description:"count of redirection"`
	EventID   *string            `json:"event_id" bson:"event_id" example:"5f9e9b9b9b9b9b9b9b9b9b98" description:"event id"`
	UserID    *string            `json:"user_id" bson:"user_id" example:"5f9e9b9b9b9b9b9b9b9b9b9b" description:"user id"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at" example:"2020-10-31T00:00:00Z"`
	UpdatedAt *time.Time         `json:"updated_at" bson:"updated_at" example:"2020-10-31T00:00:00Z"`
	DeletedAt *time.Time         `json:"deleted_at" bson:"deleted_at" example:"2020-10-31T00:00:00Z"`
}

func (URLCollection) ComposeURLString

func (fetchedUrl URLCollection) ComposeURLString() string

type Work

type Work struct {
	ID    uuid.UUID `json:"id"`
	Input any

	Output any
	Error  error
	// contains filtered or unexported fields
}

type WorkerFunction

type WorkerFunction interface {
	ShortenURL(input ShortenURLRequest) (*URLCollection, error)
	CheckHealth() (string, error)
}

type WorkerFunctionsAdapter

type WorkerFunctionsAdapter struct {
	BaseURL string
}

func NewWorkerFunctionsAdapter

func NewWorkerFunctionsAdapter(baseURL string) *WorkerFunctionsAdapter

func (*WorkerFunctionsAdapter) CheckHealth

func (w *WorkerFunctionsAdapter) CheckHealth() (string, error)

func (*WorkerFunctionsAdapter) ShortenURL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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