persistence

package
v0.0.0-...-9a70a3a Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataFileName = "metadata.pb"
	AccountFileName  = "account.pb"
)

Variables

This section is empty.

Functions

func ConversationName

func ConversationName(metadata *proto.ConversationMetadata) string

func MessageName

func MessageName(date time.Time, sender string) string

func ReadConversationMetadata

func ReadConversationMetadata(dir string) (*proto.ConversationMetadata, error)

func UnmarshalFromFile

func UnmarshalFromFile(path string, out interface {
	Unmarshal([]byte) error
}) error

Unmarshal reads an Unmarshal()-able from a file

Types

type Message

type Message struct {
	Path, Sender, Content string
}

func ReadMessageFromFile

func ReadMessageFromFile(path string) (*Message, error)

type Paths

type Paths struct {
	RootDir     string
	Application string
}

func (*Paths) AccountPath

func (p *Paths) AccountPath() string

func (*Paths) AtomicWriteFile

func (p *Paths) AtomicWriteFile(path string, bs []byte, perm os.FileMode) error

func (*Paths) ConversationDir

func (p *Paths) ConversationDir() string

func (*Paths) ConversationToOutbox

func (p *Paths) ConversationToOutbox(metadata *proto.ConversationMetadata, msgs ...string) error

func (*Paths) ListConversations

func (p *Paths) ListConversations() ([]*proto.ConversationMetadata, error)

func (*Paths) LoadMessages

func (p *Paths) LoadMessages(conv *proto.ConversationMetadata) ([]*Message, error)

func (*Paths) MarshalToFile

func (p *Paths) MarshalToFile(path string, in interface {
	Marshal() ([]byte, error)
}) error

MarshalToFile atomically writes a Marshal()-able object to a file by first writing to a new file in tmpDir and then atomically renaming it to the destination file.

func (*Paths) MessageToOutbox

func (p *Paths) MessageToOutbox(conversationName, message string) error

func (*Paths) MkdirInTemp

func (p *Paths) MkdirInTemp() (string, error)

func (*Paths) OutboxDir

func (p *Paths) OutboxDir() string

func (*Paths) TempDir

func (p *Paths) TempDir() string

func (*Paths) TempFile

func (p *Paths) TempFile() (string, error)

Jump to

Keyboard shortcuts

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