package module
Version: v0.0.0-...-872cf84 Latest Latest

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

Go to latest
Published: Feb 25, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0


Joe Bot - gokv Adapter

Build Status codecov Go Report Card CodeFactor License

Integration Joe with gokv.

Getting Started

To install:

go get github.com/tdakkota/joe-gokv-memory

gokv currently does not support GetAll/Keys operations(see this issue)

Package provides Keys interface to store list of keys(by default map used).

Example usage
package main

import (

type Bot struct {

func main() {
	store, err := redis.NewClient(redis.DefaultOptions)
	if err != nil {

	b := Bot{joe.New(
	b.Respond("remember (.+) is (.+)", b.Remember)
	b.Respond("what is (.+)", b.WhatIs)

	err = b.Run()
	if err != nil {

func (b *Bot) Remember(msg joe.Message) error {
	key, value := msg.Matches[0], msg.Matches[1]
	msg.Respond("OK, I'll remember %s is %s", key, value)
	return b.Store.Set(key, value)

func (b *Bot) WhatIs(msg joe.Message) error {
	key := msg.Matches[0]
	var value string
	ok, err := b.Store.Get(key, &value)
	if err != nil {
		return err
	if ok {
		msg.Respond("%s is %s", key, value)
	} else {
		msg.Respond("I do not remember %q", key)
	return nil






This section is empty.


This section is empty.


func Memory

func Memory(store gokv.Store) joe.Module

Memory creates a joe.Module


type Keys

type Keys interface {
	OnAdd(key string)
	OnDelete(key string)
	Keys() []string

Keys is abstraction for keys list

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields

func NewMemory

func NewMemory(store gokv.Store, options ...Option) (*MemoryStore, error)

NewMemory is MemoryStore struct constructor

func (MemoryStore) Close

func (m MemoryStore) Close() error

func (MemoryStore) Delete

func (m MemoryStore) Delete(key string) (bool, error)

func (MemoryStore) Get

func (m MemoryStore) Get(key string) (value []byte, ok bool, err error)

func (MemoryStore) Keys

func (m MemoryStore) Keys() ([]string, error)

func (MemoryStore) Set

func (m MemoryStore) Set(key string, value []byte) error

type Option

type Option func(*MemoryStore) error

Option func

func WithKeys

func WithKeys(keys Keys) Option

WithKeys is Option func which sets the instance of Keys

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger is Option func which sets the instance of logger


Path Synopsis

Jump to

Keyboard shortcuts

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