server

package module
v0.0.0-...-71dc6ea Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, url string, secretKey string, tokenKey string, opts *ServeOptions) error

ListenAndServe starts the server.

func NewRedisPool

func NewRedisPool() *redis.Pool

NewRedisPool from env.

func Serve

func Serve(hub *Hub, tokenKey *[32]byte, w http.ResponseWriter, r *http.Request)

Serve handles websocket requests from the peer.

Types

type Hub

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

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub(url string) *Hub

NewHub ...

func (*Hub) Run

func (h *Hub) Run()

Run hub.

type Redis

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

Redis ...

func NewRedis

func NewRedis(hub *Hub, secretKey *[32]byte) *Redis

NewRedis ...

func (*Redis) Delete

func (r *Redis) Delete(ctx context.Context, k string) error

Delete value.

func (*Redis) Expire

func (r *Redis) Expire(ctx context.Context, k string, dt time.Duration) error

Expire value.

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, k string) (string, error)

Get value.

func (*Redis) Increment

func (r *Redis) Increment(ctx context.Context, k string) (int64, error)

Increment value.

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, k string, v string) error

Set value.

func (*Redis) Subscribe

func (r *Redis) Subscribe() error

Subscribe ...

type ServeOptions

type ServeOptions struct{}

ServeOptions ...

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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