client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package client provides utilities for working with the pomodoro server.

Index

Constants

View Source
const (
	// CheckTimer checks the status of the timer.
	CheckTimer = "is-ticking"
	// CloseConn tells the server to close the connection.
	CloseConn = "close"
	// StartTimer starts a new timer.
	StartTimer = "start"
	// StopTimer stops the timer.
	StopTimer = "stop"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a single client connection to the server.

func New

func New() (context.Context, Client)

New returns a new client instance.

func (*Client) Close

func (cl *Client) Close(ctx context.Context)

Close closes the connection to the server and cleans up the context.

func (*Client) Send

func (cl *Client) Send(ctx context.Context, m Mode) (Resp, error)

Send sends a command to the server.

type Cmd

type Cmd struct {
	Mode string `json:"mode"`
}

Cmd is a command to send to the server.

func (Cmd) MarshalZerologObject

func (c Cmd) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zapcore.LogObjectMarshaler.

type Mode

type Mode string

Mode is the command to be sent to the server.

func (Mode) String

func (m Mode) String() string

type Resp

type Resp struct {
	Duration      string `json:"duration,omitempty"`
	Session       string `json:"session,omitempty"`
	Ticking       bool   `json:"ticking"`
	TimeRemaining string `json:"timeRemaining,omitempty"`
}

Resp is the data returned from the server.

func (Resp) MarshalZerologObject

func (r Resp) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zapcore.LogObjectMarshaler.

Jump to

Keyboard shortcuts

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