arcade

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

arcade

export player_id=$(uuidgen) export player_name=Somebody export player_desc="A person of importance." export home_id=$(uuidgen) export location_id=$(uuidgen)

dev run curl --request POST --data '{ "playerID": "'"${player_id}"'", "name": "'"${player_name}"'", "description": "'"${player_desc}"'", "home": "'"${home_id}"'", "location": "'"${location_id}"'" }' "https://assets:4201/players"

dev run curl --request GET "https://assets:4201/players"

dev run curl --request GET "https://assets:4201/players/${player_id}"

Documentation

Index

Constants

View Source
const (
	MaxItemNameLen        = 255
	MaxItemDescriptionLen = 4096
)
View Source
const (
	MaxLinkNameLen        = 255
	MaxLinkDescriptionLen = 4096
)
View Source
const (
	MaxPlayerNameLen          = 255
	MaxPlayerDescriptionLen   = 4096
	DefaultPlayersFilterLimit = 10
	MaxPlayersFilterLimit     = 100
)
View Source
const (
	MaxRoomNameLen          = 255
	MaxRoomDescriptionLen   = 4096
	DefaultRoomsFilterLimit = 10
	MaxRoomsFilterLimit     = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Health

type Health struct {
	Status string `json:"status"`
}

Health is the internal representation of the health of the system.

type HealthResponse

type HealthResponse struct {
	Data Health `json:"data"`
}

HealthResponse is used to json encoded a health response.

type Item

type Item struct {
	ID          string    `json:"itemID"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	OwnerID     string    `json:"ownerID"`
	LocationID  string    `json:"locationID"`
	InventoryID string    `json:"inventoryID"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Item is the internal representation of the data related to a item.

type ItemRequest

type ItemRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	OwnerID     string `json:"ownerID"`
	LocationID  string `json:"locationID"`
	InventoryID string `json:"inventoryID"`
}

ItemRequest is the payload of a item create or update request.

func (ItemRequest) Validate

func (r ItemRequest) Validate() (uuid.UUID, uuid.UUID, uuid.UUID, error)

Validate returns an error for an invalid item request. A vaild request will return the parsed owner and location UUIDs.

type ItemResponse

type ItemResponse struct {
	Data Item `json:"data"`
}

ItemResponse is used to json encoded a single item response.

type ItemsFilter

type ItemsFilter struct {
	// OwnerID filters for items owned by a given item.
	OwnerID *string

	// LocationID filters for items located in the given room.
	LocationID *string

	// InventoryID filters for items in the inventory of the given player.
	InventoryID *string

	// Restrict to a subset of the results.
	Offset int
	Limit  int
}

ItemsFilter is used to filter results from a List.

type ItemsResponse

type ItemsResponse struct {
	Data []Item `json:"data"`
}

ItemsResponse is used to json encoded a multi-item response.

func NewItemsResponse

func NewItemsResponse(rs []Item) ItemsResponse

NewItemsResponse returns a items response given a slice of items.

type ItemsStorage added in v0.0.10

type ItemsStorage interface {
	// List returns a slice of items based on the value of the filter.
	List(ctx context.Context, filter ItemsFilter) ([]Item, error)

	// Get returns a single item given the itemID.
	Get(ctx context.Context, itemID string) (Item, error)

	// Create a item given the item request, returning the creating item.
	Create(ctx context.Context, req ItemRequest) (Item, error)

	// Update a item given the item request, returning the updated item.
	Update(ctx context.Context, itemID string, req ItemRequest) (Item, error)

	// Remove deletes the given item from persistent storage.
	Remove(ctx context.Context, itemID string) error
}

ItemsStorage represents the persistent storage of items.

type Link struct {
	ID            string    `json:"linkID"`
	Name          string    `json:"name"`
	Description   string    `json:"description"`
	OwnerID       string    `json:"ownerID"`
	LocationID    string    `json:"locationID"`
	DestinationID string    `json:"destinationID"`
	Created       time.Time `json:"created"`
	Updated       time.Time `json:"updated"`
}

Link is the internal representation of the data related to a link.

type LinkRequest

type LinkRequest struct {
	Name          string `json:"name"`
	Description   string `json:"description"`
	OwnerID       string `json:"ownerID"`
	LocationID    string `json:"locationID"`
	DestinationID string `json:"destinationID"`
}

LinkRequest is the payload of a link create or update request.

func (LinkRequest) Validate

func (r LinkRequest) Validate() (uuid.UUID, uuid.UUID, uuid.UUID, error)

Validate returns an error for an invalid link request. A vaild request will return the parsed owner and location UUIDs.

type LinkResponse

type LinkResponse struct {
	Data Link `json:"data"`
}

LinkResponse is used to json encoded a single link response.

type LinksFilter

type LinksFilter struct {
	// OwnerID filters for links owned by a given link.
	OwnerID *string

	// LocationID filters for links located in a location link (non-recursive).
	LocationID *string

	// DestinationID filters for links connected to the given destination.
	DestinationID *string

	// Restrict to a subset of the results.
	Offset int
	Limit  int
}

LinksFilter is used to filter results from a List.

type LinksResponse

type LinksResponse struct {
	Data []Link `json:"data"`
}

LinksResponse is used to json encoded a multi-link response.

func NewLinksResponse

func NewLinksResponse(rs []Link) LinksResponse

NewLinksResponse returns a links response given a slice of links.

type LinksStorage added in v0.0.10

type LinksStorage interface {
	// List returns a slice of links based on the value of the filter.
	List(ctx context.Context, filter LinksFilter) ([]Link, error)

	// Get returns a single link given the linkID.
	Get(ctx context.Context, linkID string) (Link, error)

	// Create a link given the link request, returning the creating link.
	Create(ctx context.Context, req LinkRequest) (Link, error)

	// Update a link given the link request, returning the updated link.
	Update(ctx context.Context, linkID string, req LinkRequest) (Link, error)

	// Remove deletes the given link from persistent storage.
	Remove(ctx context.Context, linkID string) error
}

LinksStorage represents the persistent storage of links.

type Player

type Player struct {
	ID          string    `json:"playerID"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	HomeID      string    `json:"homeID"`
	LocationID  string    `json:"locationID"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Player is the internal representation of the data related to a player.

type PlayerRequest

type PlayerRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	HomeID      string `json:"homeID"`
	LocationID  string `json:"locationID"`
}

PlayerRequest is the payload of a player create or update request.

func (PlayerRequest) Validate

func (r PlayerRequest) Validate() (uuid.UUID, uuid.UUID, error)

Validate returns an error for an invalid player request. A vaild request will return the parsed home and location UUIDs.

type PlayerResponse

type PlayerResponse struct {
	Data Player `json:"data"`
}

PlayerResponse is used to json encoded a single player response.

type PlayersFilter

type PlayersFilter struct {
	// LocationID filters for players in a given location.
	LocationID *uuid.UUID

	// Restrict to a subset of the results.
	Offset int
	Limit  int
}

PlayersFilter is used to filter results from List.

func NewPlayersFilter added in v0.0.10

func NewPlayersFilter(r *http.Request) (PlayersFilter, error)

NewPlayersFilter creates a PlayersFilter from the the given request's URL query parameters

type PlayersResponse

type PlayersResponse struct {
	Data []Player `json:"data"`
}

PlayersResponse is used to json encoded a multi-player resposne.

func NewPlayersResponse

func NewPlayersResponse(ps []Player) PlayersResponse

NewPlayersResponse returns a players response given a slice of players.

type PlayersStorage added in v0.0.10

type PlayersStorage interface {
	// List returns a slice of players based on the value of the filter.
	List(ctx context.Context, filter PlayersFilter) ([]Player, error)

	// Get returns a single player given the playerID.
	Get(ctx context.Context, playerID string) (Player, error)

	// Create a player given the player request, returning the creating player.
	Create(ctx context.Context, req PlayerRequest) (Player, error)

	// Update a player given the player request, returning the updated player.
	Update(ctx context.Context, playerID string, req PlayerRequest) (Player, error)

	// Remove deletes the given player from persistent storage.
	Remove(ctx context.Context, playerID string) error
}

PlayersStorage represents the persistent storage of players.

type Room

type Room struct {
	ID          string    `json:"roomID"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	OwnerID     string    `json:"ownerID"`
	ParentID    string    `json:"parentID"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Room is the internal representation of the data related to a room.

type RoomRequest

type RoomRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	OwnerID     string `json:"ownerID"`
	ParentID    string `json:"parentID"`
}

RoomRequest is the payload of a room create or update request.

func (RoomRequest) Validate

func (r RoomRequest) Validate() (uuid.UUID, uuid.UUID, error)

Validate returns an error for an invalid room request. A vaild request will return the parsed owner and parent UUIDs.

type RoomResponse

type RoomResponse struct {
	Data Room `json:"data"`
}

RoomResponse is used to json encoded a single room response.

type RoomsFilter

type RoomsFilter struct {
	// OwnerID filters for rooms owned by a given room.
	OwnerID *uuid.UUID

	// ParentID filters for rooms located in a parent room (non-recursive).
	ParentID *uuid.UUID

	// Restrict to a subset of the results.
	Offset int
	Limit  int
}

RoomsFilter is used to filter results from a List.

func NewRoomsFilter added in v0.0.10

func NewRoomsFilter(r *http.Request) (RoomsFilter, error)

NewRoomsFilter creates a RoomsFilter from the the given request's URL query parameters

type RoomsResponse

type RoomsResponse struct {
	Data []Room `json:"data"`
}

RoomsResponse is used to json encoded a multi-room response.

func NewRoomsResponse

func NewRoomsResponse(rs []Room) RoomsResponse

NewRoomsResponse returns a rooms response given a slice of rooms.

type RoomsStorage added in v0.0.10

type RoomsStorage interface {
	// List returns a slice of rooms based on the value of the filter.
	List(ctx context.Context, filter RoomsFilter) ([]Room, error)

	// Get returns a single room given the roomID.
	Get(ctx context.Context, roomID string) (Room, error)

	// Create a room given the room request, returning the creating room.
	Create(ctx context.Context, req RoomRequest) (Room, error)

	// Update a room given the room request, returning the updated room.
	Update(ctx context.Context, roomID string, req RoomRequest) (Room, error)

	// Remove deletes the given room from persistent storage.
	Remove(ctx context.Context, roomID string) error
}

RoomsStorage represents the persistent storage of rooms.

type StorageDriver

type StorageDriver interface {
	// PlayersListQuery returns the List query string given the filter.
	PlayersListQuery(PlayersFilter) string

	// PlayersGetQuery returns the Get query string.
	PlayersGetQuery() string

	// PlayersCreateQuery returns the Create query string.
	PlayersCreateQuery() string

	// PlayersUpdateQuery returns the update query string.
	PlayersUpdateQuery() string

	// PlayersRemoveQuery returns the Remove query string.
	PlayersRemoveQuery() string

	// RoomListQuery returns the List query string given the filter.
	RoomsListQuery(RoomsFilter) string

	// RoomsGetQuery returns the Get query string.
	RoomsGetQuery() string

	// RoomsCreateQuery returns the Create query string.
	RoomsCreateQuery() string

	// RoomsUpdateQuery returns the Update query string.
	RoomsUpdateQuery() string

	// RoomsRemoveQuery returns the Remove query string.
	RoomsRemoveQuery() string

	// LinksListQuery returns the List query string given the filter.
	LinksListQuery(LinksFilter) string

	// LinksGetQuery returns the Get query string.
	LinksGetQuery() string

	// LinksCreateQuery returns the Create query string.
	LinksCreateQuery() string

	// LinksUpdateQuery returns the Update query string.
	LinksUpdateQuery() string

	// LinksRemoveQuery returns the Remove query string.
	LinksRemoveQuery() string

	// ItemsListQuery returns the List query string given the filter.
	ItemsListQuery(ItemsFilter) string

	// ItemsGetQuery returns the Get query string.
	ItemsGetQuery() string

	// ItemsCreateQuery returns the Create query string.
	ItemsCreateQuery() string

	// ItemsUpdateQuery returns the Update query string.
	ItemsUpdateQuery() string

	// ItemsRemoveQuery returns the Remove query string.
	ItemsRemoveQuery() string

	// IsForeignKeyViolation returns true if the given error is a foreign key violation error.
	IsForeignKeyViolation(err error) bool

	// IsUniqueViolation returns true if the given error is a unique violation error.
	IsUniqueViolation(err error) bool
}

Storage represents the SQL driver specific functionality.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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