avengersclient

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: GPL-2.0 Imports: 7 Imported by: 1

README

avengers-client

go client to interact with sourav977/avengers-backend server

Documentation

Index

Constants

View Source
const (
	HostURL              = "http://localhost:8000" // Default avengers-backend URL
	DEFAULT_HTTP_TIMEOUT = 10 * time.Second
	InitialBackoffDelay  = 1 * time.Second
	MaxBackoffDelay      = 16 * time.Second // MaxBackoffDelay is a DelayType which increases delay between consecutive retries
	MaxRetries           = 5
)

Variables

View Source
var Strategy = retry.LimitCount(MaxRetries, retry.Exponential{
	Initial:  InitialBackoffDelay,
	Factor:   2,
	MaxDelay: MaxBackoffDelay,
})

Functions

This section is empty.

Types

type Avenger

type Avenger struct {
	ID     string `json:"_id,omitempty"`
	Name   string `json:"name,omitempty"`
	Alias  string `json:"alias,omitempty"`
	Weapon string `json:"weapon,omitempty"`
}

type Client

type Client struct {
	HostURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(host *string, clock retry.Clock, strategy retry.Strategy) (*Client, error)

func (*Client) CreateAvenger

func (c *Client) CreateAvenger(avenger Avenger) (*Avenger, error)

CreateAvenger will create an Avenger

func (*Client) DeleteAvengerByName

func (c *Client) DeleteAvengerByName(avengerName string) (*DeleteResult, error)

DeleteAvengerByName will delete an Avenger

func (*Client) DoRequest

func (c *Client) DoRequest(req *http.Request) ([]byte, error)

DoRequest will actually make a call to avengers-backend

func (Client) GetAllAvengers

func (c Client) GetAllAvengers() ([]Avenger, error)

GetAllAvengers returns list of Avengers

func (*Client) UpdateAvengerByName

func (c *Client) UpdateAvengerByName(avenger Avenger) (*UpdateResult, error)

UpdateAvengerByName will update an Avenger

type DeleteResult

type DeleteResult struct {
	DeletedCount int `json:"deletedCount,omitempty"`
}

type InsertedResult

type InsertedResult struct {
	InsertedID string `json:"insertedID,omitempty"` //example "61dd1635b9fd2fb647c16b09"
}

type UpdateResult

type UpdateResult struct {
	MatchedCount  int `json:"matchedCount,omitempty"`
	ModifiedCount int `json:"modifiedCount,omitempty"`
	UpsertedCount int `json:"upsertedCount,omitempty"`
}

Jump to

Keyboard shortcuts

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