account

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: ISC Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheDir             = "cache"
	UserIdentityFilename = "user.ini"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {

	// mutexed memebers
	sync.Mutex
	// contains filtered or unexported fields
}

Account opaque type that handles account related services.

func New

func New(root string) (*Account, error)

New initializes an Account context. It creates the containing directory and launches the push channel handling. Note that New walks the root directory and removes stale locks. The directory walk is slow and this call may take a while to complete.

func (*Account) Create

func (a *Account) Create(pid zkidentity.PublicIdentity, force bool) error

createAccount creates all directories and files associated with an account. It returns a logable and a sanitized error.

func (*Account) Delete

func (a *Account) Delete(from [zkidentity.IdentitySize]byte, identifier string) error

func (*Account) Deliver

func (a *Account) Deliver(to [zkidentity.IdentitySize]byte, from [zkidentity.IdentitySize]byte, payload []byte, cleartext bool) (string, error)

Deliver physically drops a message on disk. It returns the fullpath so that callers can pretty log deliveries.

func (*Account) Disable added in v0.4.0

func (a *Account) Disable(pid [zkidentity.IdentitySize]byte) error

func (*Account) Disabled added in v0.4.0

func (a *Account) Disabled(pid [zkidentity.IdentitySize]byte) bool

func (*Account) Enable added in v0.4.0

func (a *Account) Enable(pid [zkidentity.IdentitySize]byte) error

func (*Account) Enabled added in v0.4.0

func (a *Account) Enabled(pid [zkidentity.IdentitySize]byte) bool

func (*Account) Find added in v0.2.0

func (a *Account) Find(nick string) (*zkidentity.PublicIdentity, error)

func (*Account) Offline

func (a *Account) Offline(who [zkidentity.IdentitySize]byte)

Offline knocks a user offline. This function must be called WITHOUT the mutex held.

func (*Account) Online

func (a *Account) Online(who [zkidentity.IdentitySize]byte, ntfn chan *Notification) error

Online notifies Account that a user has become available. It reads all undelivered messages of disk and uses the Notification channel to propagate them.

func (*Account) Pull added in v0.2.0

func (a *Account) Pull(id [zkidentity.IdentitySize]byte) error

func (*Account) Push added in v0.2.0

func (a *Account) Push(id [zkidentity.IdentitySize]byte) error

type ErrAlreadyOnline added in v0.4.0

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

func (ErrAlreadyOnline) Error added in v0.4.0

func (e ErrAlreadyOnline) Error() string

type Notification

type Notification struct {
	To         [zkidentity.IdentitySize]byte
	From       [zkidentity.IdentitySize]byte
	Received   int64 // received time
	Payload    []byte
	Cleartext  bool // Set when payload is clear text
	Identifier string
	Error      error
}

Notification contains the necessary information to notify the caller that a delivery has been made. Notifications are written opportunistically and non blocking. It is the receivers responsibility to read the channel queue quickly enough. This usually means that the channel should be created with some sane queue depth!

Jump to

Keyboard shortcuts

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