lib

package
v0.0.0-...-eb31e87 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PubsubUser = "default"
)

Functions

func AddMessage

func AddMessage(body string, author string, clientTime time.Time, ds datas.Dataset) (datas.Dataset, error)

func GetAuthors

func GetAuthors(ds datas.Dataset) []string

func GetTerms

func GetTerms(m Message) []string

func IndexNewMessage

func IndexNewMessage(vrw types.ValueReadWriter, root *Root, m Message)

func InitDatabase

func InitDatabase(ds datas.Dataset) (datas.Dataset, error)

func ListMessages

func ListMessages(ds datas.Dataset, searchIds *types.Map, doneChan chan struct{}) (msgMap types.Map, mc chan types.String, err error)

func NewDataPager

func NewDataPager(ds datas.Dataset, mkChan chan types.String, doneChan chan struct{}, msgs types.Map, terms []string) *dataPager

func NewLogger

func NewLogger(username string) *log.Logger

func ProcessChatEvents

func ProcessChatEvents(node *core.IpfsNode, ds datas.Dataset, events chan ChatEvent, t *TermUI, cInfo ClientInfo)

ProcessChatEvent reads events from the event channel and processes them sequentially. Is ClientInfo.IsDaemon is true, it also publishes the current head of the dataset continously.

func Publish

func Publish(node *core.IpfsNode, cInfo ClientInfo, h hash.Hash)

Publish asks the delegate to format a hash/ClientInfo into a suitable msg and publishes that using IPFS pubsub.

func ReceiveMessages

func ReceiveMessages(node *core.IpfsNode, events chan ChatEvent, cInfo ClientInfo)

RecieveMessages listens for messages sent by other chat nodes. It filters out any msgs that have already been received and adds events to teh events channel for any msgs that it hasn't seen yet.

func RunImport

func RunImport(dir, dsSpec string) error

func SearchIndex

func SearchIndex(ds datas.Dataset, search []string) types.Map

func TermsFromString

func TermsFromString(s string) []string

Types

type ChatEvent

type ChatEvent struct {
	EventType ChatEventType
	Event     string
}

type ChatEventType

type ChatEventType string
const (
	InputEvent  ChatEventType = "input"
	SearchEvent ChatEventType = "search"
	SyncEvent   ChatEventType = "sync"
	QuitEvent   ChatEventType = "quit"
)

type ClientInfo

type ClientInfo struct {
	Topic    string
	Username string
	Interval time.Duration
	Idx      int
	IsDaemon bool
	Dir      string
	Spec     spec.Spec
	Delegate EventDelegate
}

type EventDelegate

type EventDelegate interface {
	PinBlocks(node *core.IpfsNode, sourceDB, sinkDB datas.Database, sourceCommit types.Value)
	SourceCommitFromMsgData(db datas.Database, msgData string) (datas.Database, types.Value)
	HashFromMsgData(msgData string) (hash.Hash, error)
	GenMessageData(cInfo ClientInfo, h hash.Hash) string
}

type IPFSEventDelegate

type IPFSEventDelegate struct{}

func (IPFSEventDelegate) GenMessageData

func (d IPFSEventDelegate) GenMessageData(cInfo ClientInfo, h hash.Hash) string

func (IPFSEventDelegate) HashFromMsgData

func (d IPFSEventDelegate) HashFromMsgData(msgData string) (hash.Hash, error)

func (IPFSEventDelegate) PinBlocks

func (d IPFSEventDelegate) PinBlocks(node *core.IpfsNode, sourceDB, sinkDB datas.Database, sourceCommit types.Value)

func (IPFSEventDelegate) SourceCommitFromMsgData

func (d IPFSEventDelegate) SourceCommitFromMsgData(db datas.Database, msgData string) (datas.Database, types.Value)

type Message

type Message struct {
	Ordinal    uint64
	Author     string
	Body       string
	ClientTime datetime.DateTime
}

func (Message) ID

func (m Message) ID() string

type P2PEventDelegate

type P2PEventDelegate struct{}

func (P2PEventDelegate) GenMessageData

func (d P2PEventDelegate) GenMessageData(cInfo ClientInfo, h hash.Hash) string

func (P2PEventDelegate) HashFromMsgData

func (d P2PEventDelegate) HashFromMsgData(msgData string) (hash.Hash, error)

func (P2PEventDelegate) PinBlocks

func (d P2PEventDelegate) PinBlocks(node *core.IpfsNode, sourceDB, sinkDB datas.Database, sourceCommit types.Value)

func (P2PEventDelegate) SourceCommitFromMsgData

func (d P2PEventDelegate) SourceCommitFromMsgData(db datas.Database, msgData string) (datas.Database, types.Value)

type Root

type Root struct {
	// Map<Key, Message>
	// Keys are strings like: <Ordinal>,<Author>
	// This scheme allows:
	// - map is naturally sorted in the right order
	// - conflicts will generally be avoided
	// - messages are editable
	Messages types.Map
	Index    types.Map
	Users    []string `noms:",set"`
}

type TermIndex

type TermIndex struct {
	TermDocs types.Map
	// contains filtered or unexported fields
}

func NewTermIndex

func NewTermIndex(vrw types.ValueReadWriter, TermDocs types.Map) TermIndex

func (TermIndex) Edit

func (ti TermIndex) Edit() *TermIndexEditor

func (TermIndex) Search

func (ti TermIndex) Search(terms []string) types.Map

type TermIndexEditor

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

func (*TermIndexEditor) Insert

func (te *TermIndexEditor) Insert(term string, v types.Value) *TermIndexEditor

Indexes |v| by |term|

func (*TermIndexEditor) InsertAll

func (te *TermIndexEditor) InsertAll(terms []string, v types.Value) *TermIndexEditor

Indexes |v| by each unique term in |terms| (tolerates duplicate terms)

func (*TermIndexEditor) Value

func (te *TermIndexEditor) Value() TermIndex

Builds a new TermIndex

type TermUI

type TermUI struct {
	Gui      *gocui.Gui
	InSearch bool
	// contains filtered or unexported fields
}

func CreateTermUI

func CreateTermUI(events chan ChatEvent) *TermUI

func (*TermUI) Close

func (t *TermUI) Close()

func (*TermUI) Layout

func (t *TermUI) Layout() error

func (*TermUI) ResetAuthors

func (t *TermUI) ResetAuthors(ds datas.Dataset)

func (*TermUI) UpdateMessages

func (t *TermUI) UpdateMessages(ds datas.Dataset, filterIds *types.Map, terms []string) error

func (*TermUI) UpdateMessagesAsync

func (t *TermUI) UpdateMessagesAsync(ds datas.Dataset, sids *types.Map, terms []string)

func (*TermUI) UpdateMessagesFromSync

func (t *TermUI) UpdateMessagesFromSync(ds datas.Dataset)

Jump to

Keyboard shortcuts

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