redis

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package redis connects to a redis database to fetch database updates and logout events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockingConn

type BlockingConn struct{}

BlockingConn is a fake implementation of the redis connection. It does not create a connection but blocks forever.

func (BlockingConn) XADD

func (BlockingConn) XADD(stream, key string, value []byte) error

XADD does nothing.

func (BlockingConn) XREAD

func (BlockingConn) XREAD(count, stream, id string) (interface{}, error)

XREAD blocks forever.

func (BlockingConn) ZINCR

func (BlockingConn) ZINCR(key string, value []byte) error

ZINCR does nothing.

func (BlockingConn) ZRANGE

func (BlockingConn) ZRANGE(key string) (interface{}, error)

ZRANGE does nothing.

type Connection

type Connection interface {
	XREAD(count, stream, lastID string) (interface{}, error)
	ZINCR(key string, value []byte) error
	ZRANGE(key string) (interface{}, error)
	XADD(stream, field string, value []byte) error
}

Connection is the raw connection to a redis server.

type Pool

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

Pool hold the redis connection.

func NewConnection

func NewConnection(addr string) *Pool

NewConnection creates a new pool.

func (*Pool) TestConn

func (s *Pool) TestConn() error

TestConn sends a ping command to redis. Does not return the response, but an error if there is no response.

func (*Pool) XADD

func (s *Pool) XADD(stream, field string, value []byte) error

XADD updates a field with a value.

func (*Pool) XREAD

func (s *Pool) XREAD(count, stream, id string) (interface{}, error)

XREAD reads new messages from one stream.

func (*Pool) ZINCR

func (s *Pool) ZINCR(key string, value []byte) error

ZINCR increments a sorted set by one.

func (*Pool) ZRANGE

func (s *Pool) ZRANGE(key string) (interface{}, error)

ZRANGE returns all values from a sorted set with the scores.

type Redis

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

Redis holds the state of the redis receiver.

func (*Redis) LogoutEvent

func (r *Redis) LogoutEvent(ctx context.Context) ([]string, error)

LogoutEvent is a blocking function that returns, when a session was revoked.

func (*Redis) Publish

func (r *Redis) Publish(ctx context.Context, key string, value []byte) error

Publish updates a value on the message bus.

func (*Redis) RequestMeticSave

func (r *Redis) RequestMeticSave(request []byte) error

RequestMeticSave saves how often a request was send.

func (*Redis) RequestMetricGet

func (r *Redis) RequestMetricGet(w io.Writer) error

RequestMetricGet writes all request with there count as json.

func (*Redis) Update

func (r *Redis) Update(ctx context.Context) (map[string][]byte, error)

Update is a blocking function that returns, when there is new data.

Jump to

Keyboard shortcuts

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