gregor1

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2017 License: BSD-3-Clause, BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthInternalProtocol

func AuthInternalProtocol(i AuthInternalInterface) rpc.Protocol

func AuthProtocol

func AuthProtocol(i AuthInterface) rpc.Protocol

func AuthUpdateProtocol

func AuthUpdateProtocol(i AuthUpdateInterface) rpc.Protocol

func CommonProtocol

func CommonProtocol(i CommonInterface) rpc.Protocol

func FormatTime

func FormatTime(t Time) string

func FromTime

func FromTime(t Time) time.Time

func IncomingProtocol

func IncomingProtocol(i IncomingInterface) rpc.Protocol

func OutgoingProtocol

func OutgoingProtocol(i OutgoingInterface) rpc.Protocol

func RemindProtocol

func RemindProtocol(i RemindInterface) rpc.Protocol

func UIDListContains added in v1.0.19

func UIDListContains(list []UID, x UID) bool

Types

type AuthClient

type AuthClient struct {
	Cli rpc.GenericClient
}

func (AuthClient) AuthenticateSessionToken

func (c AuthClient) AuthenticateSessionToken(ctx context.Context, session SessionToken) (res AuthResult, err error)

type AuthInterface

type AuthInterface interface {
	AuthenticateSessionToken(context.Context, SessionToken) (AuthResult, error)
}

type AuthInternalClient

type AuthInternalClient struct {
	Cli rpc.GenericClient
}

func (AuthInternalClient) CreateGregorSuperUserSessionToken

func (c AuthInternalClient) CreateGregorSuperUserSessionToken(ctx context.Context) (res SessionToken, err error)

type AuthInternalInterface

type AuthInternalInterface interface {
	CreateGregorSuperUserSessionToken(context.Context) (SessionToken, error)
}

type AuthResult

type AuthResult struct {
	Uid      UID       `codec:"uid" json:"uid"`
	Username string    `codec:"username" json:"username"`
	Sid      SessionID `codec:"sid" json:"sid"`
	IsAdmin  bool      `codec:"isAdmin" json:"isAdmin"`
}

type AuthUpdateClient

type AuthUpdateClient struct {
	Cli rpc.GenericClient
}

func (AuthUpdateClient) RevokeSessionIDs

func (c AuthUpdateClient) RevokeSessionIDs(ctx context.Context, sessionIDs []SessionID) (err error)

type AuthUpdateInterface

type AuthUpdateInterface interface {
	RevokeSessionIDs(context.Context, []SessionID) error
}

type AuthenticateSessionTokenArg

type AuthenticateSessionTokenArg struct {
	Session SessionToken `codec:"session" json:"session"`
}

type Body

type Body []byte

func (Body) Bytes

func (b Body) Bytes() []byte

type BroadcastMessageArg

type BroadcastMessageArg struct {
	M Message `codec:"m" json:"m"`
}

type Category

type Category string

func (Category) Eq

func (c Category) Eq(c2 Category) bool

func (Category) HasPrefix

func (c Category) HasPrefix(c2 Category) bool

func (Category) String

func (c Category) String() string

type CommonClient

type CommonClient struct {
	Cli rpc.GenericClient
}

type CommonInterface

type CommonInterface interface {
}

type ConsumeMessageArg

type ConsumeMessageArg struct {
	M Message `codec:"m" json:"m"`
}

type ConsumePublishMessageArg

type ConsumePublishMessageArg struct {
	M Message `codec:"m" json:"m"`
}

type CreateGregorSuperUserSessionTokenArg

type CreateGregorSuperUserSessionTokenArg struct {
}

type DeleteRemindersArg

type DeleteRemindersArg struct {
	ReminderIDs []ReminderID `codec:"reminderIDs" json:"reminderIDs"`
}

type DeviceID

type DeviceID []byte

func (DeviceID) Bytes

func (d DeviceID) Bytes() []byte

func (DeviceID) String

func (d DeviceID) String() string

type Dismissal

type Dismissal struct {
	MsgIDs_ []MsgID    `codec:"msgIDs" json:"msgIDs"`
	Ranges_ []MsgRange `codec:"ranges" json:"ranges"`
}

func (Dismissal) MsgIDsToDismiss

func (d Dismissal) MsgIDsToDismiss() []gregor.MsgID

func (Dismissal) RangesToDismiss

func (d Dismissal) RangesToDismiss() []gregor.MsgRange

type DurationMsec

type DurationMsec int64

type GetRemindersArg

type GetRemindersArg struct {
	MaxReminders int `codec:"maxReminders" json:"maxReminders"`
}

type InBandMessage

type InBandMessage struct {
	StateUpdate_ *StateUpdateMessage `codec:"stateUpdate,omitempty" json:"stateUpdate,omitempty"`
	StateSync_   *StateSyncMessage   `codec:"stateSync,omitempty" json:"stateSync,omitempty"`
}

func (InBandMessage) Merge

func (InBandMessage) Metadata

func (i InBandMessage) Metadata() gregor.Metadata

func (InBandMessage) ToStateSyncMessage

func (i InBandMessage) ToStateSyncMessage() gregor.StateSyncMessage

func (InBandMessage) ToStateUpdateMessage

func (i InBandMessage) ToStateUpdateMessage() gregor.StateUpdateMessage

type IncomingClient

type IncomingClient struct {
	Cli rpc.GenericClient
}

func (IncomingClient) ConsumeMessage

func (c IncomingClient) ConsumeMessage(ctx context.Context, m Message) (err error)

func (IncomingClient) ConsumePublishMessage

func (c IncomingClient) ConsumePublishMessage(ctx context.Context, m Message) (err error)

func (IncomingClient) Ping

func (c IncomingClient) Ping(ctx context.Context) (res string, err error)

func (IncomingClient) State

func (c IncomingClient) State(ctx context.Context, __arg StateArg) (res State, err error)

func (IncomingClient) StateByCategoryPrefix

func (c IncomingClient) StateByCategoryPrefix(ctx context.Context, __arg StateByCategoryPrefixArg) (res State, err error)

StateByCategoryPrefix loads the messages of the user's state whose categories are prefixed by the given prefix

func (IncomingClient) Sync

func (c IncomingClient) Sync(ctx context.Context, __arg SyncArg) (res SyncResult, err error)

func (IncomingClient) Version

func (c IncomingClient) Version(ctx context.Context, uid UID) (res string, err error)

type IncomingInterface

type IncomingInterface interface {
	Sync(context.Context, SyncArg) (SyncResult, error)
	ConsumeMessage(context.Context, Message) error
	ConsumePublishMessage(context.Context, Message) error
	Ping(context.Context) (string, error)
	Version(context.Context, UID) (string, error)
	State(context.Context, StateArg) (State, error)
	// StateByCategoryPrefix loads the messages of the user's state whose
	// categories are prefixed by the given prefix
	StateByCategoryPrefix(context.Context, StateByCategoryPrefixArg) (State, error)
}

type Item

type Item struct {
	Category_    Category       `codec:"category" json:"category"`
	Dtime_       TimeOrOffset   `codec:"dtime" json:"dtime"`
	RemindTimes_ []TimeOrOffset `codec:"remindTimes" json:"remindTimes"`
	Body_        Body           `codec:"body" json:"body"`
}

type ItemAndMetadata

type ItemAndMetadata struct {
	Md_   *Metadata `codec:"md,omitempty" json:"md,omitempty"`
	Item_ *Item     `codec:"item,omitempty" json:"item,omitempty"`
}

func (ItemAndMetadata) Body

func (i ItemAndMetadata) Body() gregor.Body

func (ItemAndMetadata) Category

func (i ItemAndMetadata) Category() gregor.Category

func (ItemAndMetadata) DTime

func (ItemAndMetadata) HasCategoryPrefix

func (i ItemAndMetadata) HasCategoryPrefix(c Category) bool

func (ItemAndMetadata) InCategory

func (i ItemAndMetadata) InCategory(c Category) bool

func (ItemAndMetadata) Metadata

func (i ItemAndMetadata) Metadata() gregor.Metadata

func (ItemAndMetadata) RemindTimes

func (i ItemAndMetadata) RemindTimes() []gregor.TimeOrOffset

func (ItemAndMetadata) String

func (i ItemAndMetadata) String() string

type Message

type Message struct {
	Oobm_ *OutOfBandMessage `codec:"oobm,omitempty" json:"oobm,omitempty"`
	Ibm_  *InBandMessage    `codec:"ibm,omitempty" json:"ibm,omitempty"`
}

func (*Message) SetCTime

func (m *Message) SetCTime(ctime time.Time)

func (Message) ToInBandMessage

func (m Message) ToInBandMessage() gregor.InBandMessage

func (Message) ToOutOfBandMessage

func (m Message) ToOutOfBandMessage() gregor.OutOfBandMessage

type Metadata

type Metadata struct {
	Uid_           UID      `codec:"uid" json:"uid"`
	MsgID_         MsgID    `codec:"msgID" json:"msgID"`
	Ctime_         Time     `codec:"ctime" json:"ctime"`
	DeviceID_      DeviceID `codec:"deviceID" json:"deviceID"`
	InBandMsgType_ int      `codec:"inBandMsgType" json:"inBandMsgType"`
}

func (Metadata) CTime

func (m Metadata) CTime() time.Time

func (Metadata) DeviceID

func (m Metadata) DeviceID() gregor.DeviceID

func (Metadata) InBandMsgType

func (m Metadata) InBandMsgType() gregor.InBandMsgType

func (Metadata) MsgID

func (m Metadata) MsgID() gregor.MsgID

func (Metadata) String

func (m Metadata) String() string

func (Metadata) UID

func (m Metadata) UID() gregor.UID

type MsgID

type MsgID []byte

func (MsgID) Bytes

func (m MsgID) Bytes() []byte

func (MsgID) String

func (m MsgID) String() string

type MsgRange

type MsgRange struct {
	EndTime_  TimeOrOffset `codec:"endTime" json:"endTime"`
	Category_ Category     `codec:"category" json:"category"`
}

func (MsgRange) Category

func (m MsgRange) Category() gregor.Category

func (MsgRange) EndTime

func (m MsgRange) EndTime() gregor.TimeOrOffset

type ObjFactory

type ObjFactory struct{}

func (ObjFactory) MakeBody

func (o ObjFactory) MakeBody(b []byte) (gregor.Body, error)

func (ObjFactory) MakeCategory

func (o ObjFactory) MakeCategory(s string) (gregor.Category, error)

func (ObjFactory) MakeDeviceID

func (o ObjFactory) MakeDeviceID(b []byte) (gregor.DeviceID, error)

func (ObjFactory) MakeDismissalByIDs

func (o ObjFactory) MakeDismissalByIDs(uid gregor.UID, msgid gregor.MsgID, devid gregor.DeviceID, ctime time.Time, ids []gregor.MsgID) (gregor.InBandMessage, error)

func (ObjFactory) MakeDismissalByRange

func (o ObjFactory) MakeDismissalByRange(uid gregor.UID, msgid gregor.MsgID, devid gregor.DeviceID, ctime time.Time, c gregor.Category, d time.Time) (gregor.InBandMessage, error)

func (ObjFactory) MakeInBandMessageFromItem

func (o ObjFactory) MakeInBandMessageFromItem(i gregor.Item) (gregor.InBandMessage, error)

func (ObjFactory) MakeItem

func (o ObjFactory) MakeItem(u gregor.UID, msgid gregor.MsgID, deviceid gregor.DeviceID, ctime time.Time, c gregor.Category, dtime *time.Time, body gregor.Body) (gregor.Item, error)

func (ObjFactory) MakeMessageFromInBandMessage

func (o ObjFactory) MakeMessageFromInBandMessage(i gregor.InBandMessage) (gregor.Message, error)

func (ObjFactory) MakeMetadata

func (o ObjFactory) MakeMetadata(uid gregor.UID, msgid gregor.MsgID, devid gregor.DeviceID, ctime time.Time, i gregor.InBandMsgType) (gregor.Metadata, error)

func (ObjFactory) MakeMsgID

func (o ObjFactory) MakeMsgID(b []byte) (gregor.MsgID, error)

func (ObjFactory) MakeOutOfBandMessage

func (o ObjFactory) MakeOutOfBandMessage(uid gregor.UID, system gregor.System, body gregor.Body) gregor.Message

func (ObjFactory) MakeReminder

func (o ObjFactory) MakeReminder(i gregor.Item, seqno int, t time.Time) (gregor.Reminder, error)

func (ObjFactory) MakeReminderID

func (o ObjFactory) MakeReminderID(u gregor.UID, msgid gregor.MsgID, seqno int) (gregor.ReminderID, error)

func (ObjFactory) MakeReminderSetFromReminders

func (o ObjFactory) MakeReminderSetFromReminders(reminders []gregor.Reminder, moreRemindersReady bool) (gregor.ReminderSet, error)

func (ObjFactory) MakeState

func (o ObjFactory) MakeState(items []gregor.Item) (gregor.State, error)

func (ObjFactory) MakeStateSyncMessage

func (o ObjFactory) MakeStateSyncMessage(uid gregor.UID, msgid gregor.MsgID, devid gregor.DeviceID, ctime time.Time) (gregor.InBandMessage, error)

func (ObjFactory) MakeStateWithLookupTable

func (o ObjFactory) MakeStateWithLookupTable(items []gregor.Item, table map[string]gregor.Item) (gregor.State, error)

func (ObjFactory) MakeSystem

func (o ObjFactory) MakeSystem(s string) (gregor.System, error)

func (ObjFactory) MakeTimeOrOffsetFromOffset

func (o ObjFactory) MakeTimeOrOffsetFromOffset(d time.Duration) (gregor.TimeOrOffset, error)

func (ObjFactory) MakeTimeOrOffsetFromTime

func (o ObjFactory) MakeTimeOrOffsetFromTime(t time.Time) (gregor.TimeOrOffset, error)

func (ObjFactory) MakeUID

func (o ObjFactory) MakeUID(b []byte) (gregor.UID, error)

func (ObjFactory) UnmarshalState

func (o ObjFactory) UnmarshalState(b []byte) (gregor.State, error)

type OutOfBandMessage

type OutOfBandMessage struct {
	Uid_    UID    `codec:"uid" json:"uid"`
	System_ System `codec:"system" json:"system"`
	Body_   Body   `codec:"body" json:"body"`
}

func (OutOfBandMessage) Body

func (o OutOfBandMessage) Body() gregor.Body

func (OutOfBandMessage) System

func (o OutOfBandMessage) System() gregor.System

func (OutOfBandMessage) UID

func (o OutOfBandMessage) UID() gregor.UID

type OutgoingClient

type OutgoingClient struct {
	Cli rpc.GenericClient
}

func (OutgoingClient) BroadcastMessage

func (c OutgoingClient) BroadcastMessage(ctx context.Context, m Message) (err error)

type OutgoingInterface

type OutgoingInterface interface {
	BroadcastMessage(context.Context, Message) error
}

type PingArg

type PingArg struct {
}

type RemindClient

type RemindClient struct {
	Cli rpc.GenericClient
}

func (RemindClient) DeleteReminders

func (c RemindClient) DeleteReminders(ctx context.Context, reminderIDs []ReminderID) (err error)

deleteReminders deletes all of the reminders by ReminderID

func (RemindClient) GetReminders

func (c RemindClient) GetReminders(ctx context.Context, maxReminders int) (res ReminderSet, err error)

getReminders gets the reminders waiting to be sent out as a batch. Get at most maxReminders back.

type RemindInterface

type RemindInterface interface {
	// getReminders gets the reminders waiting to be sent out as a batch. Get at most
	// maxReminders back.
	GetReminders(context.Context, int) (ReminderSet, error)
	// deleteReminders deletes all of the reminders by ReminderID
	DeleteReminders(context.Context, []ReminderID) error
}

type Reminder

type Reminder struct {
	Item_       ItemAndMetadata `codec:"item" json:"item"`
	Seqno_      int             `codec:"seqno" json:"seqno"`
	RemindTime_ Time            `codec:"remindTime" json:"remindTime"`
}

func (Reminder) Item

func (r Reminder) Item() gregor.Item

func (Reminder) RemindTime

func (r Reminder) RemindTime() time.Time

func (Reminder) Seqno

func (r Reminder) Seqno() int

type ReminderID

type ReminderID struct {
	Uid_   UID   `codec:"uid" json:"uid"`
	MsgID_ MsgID `codec:"msgID" json:"msgID"`
	Seqno_ int   `codec:"seqno" json:"seqno"`
}

func (ReminderID) MsgID

func (r ReminderID) MsgID() gregor.MsgID

func (ReminderID) Seqno

func (r ReminderID) Seqno() int

func (ReminderID) UID

func (r ReminderID) UID() gregor.UID

type ReminderSet

type ReminderSet struct {
	Reminders_          []Reminder `codec:"reminders" json:"reminders"`
	MoreRemindersReady_ bool       `codec:"moreRemindersReady" json:"moreRemindersReady"`
}

func (ReminderSet) MoreRemindersReady

func (r ReminderSet) MoreRemindersReady() bool

func (ReminderSet) Reminders

func (r ReminderSet) Reminders() []gregor.Reminder

type RevokeSessionIDsArg

type RevokeSessionIDsArg struct {
	SessionIDs []SessionID `codec:"sessionIDs" json:"sessionIDs"`
}

type SessionID

type SessionID string

type SessionToken

type SessionToken string

type State

type State struct {
	Items_ []ItemAndMetadata `codec:"items" json:"items"`
}

func (State) Export

func (s State) Export() (gregor.ProtocolState, error)

func (State) GetItem

func (s State) GetItem(msgID gregor.MsgID) (gregor.Item, bool)

func (State) Hash

func (s State) Hash() ([]byte, error)

func (State) Items

func (s State) Items() ([]gregor.Item, error)

func (State) ItemsInCategory

func (s State) ItemsInCategory(gc gregor.Category) ([]gregor.Item, error)

func (State) ItemsWithCategoryPrefix

func (s State) ItemsWithCategoryPrefix(gc gregor.Category) ([]gregor.Item, error)

func (State) Marshal

func (s State) Marshal() ([]byte, error)

func (State) ProtocolName

func (s State) ProtocolName() string

type StateArg

type StateArg struct {
	Uid          UID          `codec:"uid" json:"uid"`
	Deviceid     DeviceID     `codec:"deviceid" json:"deviceid"`
	TimeOrOffset TimeOrOffset `codec:"timeOrOffset" json:"timeOrOffset"`
}

type StateByCategoryPrefixArg

type StateByCategoryPrefixArg struct {
	Uid            UID          `codec:"uid" json:"uid"`
	Deviceid       DeviceID     `codec:"deviceid" json:"deviceid"`
	TimeOrOffset   TimeOrOffset `codec:"timeOrOffset" json:"timeOrOffset"`
	CategoryPrefix Category     `codec:"categoryPrefix" json:"categoryPrefix"`
}

type StateSyncMessage

type StateSyncMessage struct {
	Md_ Metadata `codec:"md" json:"md"`
}

func (StateSyncMessage) Metadata

func (s StateSyncMessage) Metadata() gregor.Metadata

type StateUpdateMessage

type StateUpdateMessage struct {
	Md_        Metadata   `codec:"md" json:"md"`
	Creation_  *Item      `codec:"creation,omitempty" json:"creation,omitempty"`
	Dismissal_ *Dismissal `codec:"dismissal,omitempty" json:"dismissal,omitempty"`
}

func (StateUpdateMessage) Creation

func (s StateUpdateMessage) Creation() gregor.Item

func (StateUpdateMessage) Dismissal

func (s StateUpdateMessage) Dismissal() gregor.Dismissal

func (StateUpdateMessage) Merge

func (StateUpdateMessage) Metadata

func (s StateUpdateMessage) Metadata() gregor.Metadata

type SyncArg

type SyncArg struct {
	Uid      UID      `codec:"uid" json:"uid"`
	Deviceid DeviceID `codec:"deviceid" json:"deviceid"`
	Ctime    Time     `codec:"ctime" json:"ctime"`
}

func (SyncArg) CTime

func (s SyncArg) CTime() time.Time

func (SyncArg) DeviceID

func (s SyncArg) DeviceID() gregor.DeviceID

DeviceID returns the deviceID in a SyncArc, or interface nil (and not gregor1.DeviceID(nil)) if not was specified.

func (SyncArg) UID

func (s SyncArg) UID() gregor.UID

UID returns the UID in a SyncArc, or interface nil (and not gregor1.UID(nil)) if not was specified.

type SyncResult

type SyncResult struct {
	Msgs []InBandMessage `codec:"msgs" json:"msgs"`
	Hash []byte          `codec:"hash" json:"hash"`
}

type System

type System string

func (System) String

func (s System) String() string

type Time

type Time int64

func TimeFromSeconds

func TimeFromSeconds(seconds int64) Time

func ToTime

func ToTime(t time.Time) Time

copied from keybase/client/go/protocol/extras.go. Consider eventually a refactor to allow this code to be shared.

func (Time) After

func (t Time) After(t2 Time) bool

func (Time) Before

func (t Time) Before(t2 Time) bool

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) Time

func (t Time) Time() time.Time

func (Time) UnixMicroseconds

func (t Time) UnixMicroseconds() int64

func (Time) UnixMilliseconds

func (t Time) UnixMilliseconds() int64

func (Time) UnixSeconds

func (t Time) UnixSeconds() int64

type TimeOrOffset

type TimeOrOffset struct {
	Time_   Time         `codec:"time" json:"time"`
	Offset_ DurationMsec `codec:"offset" json:"offset"`
}

func (TimeOrOffset) Before

func (t TimeOrOffset) Before(t2 time.Time) bool

func (TimeOrOffset) IsZero

func (t TimeOrOffset) IsZero() bool

func (TimeOrOffset) Offset

func (t TimeOrOffset) Offset() *time.Duration

func (TimeOrOffset) Time

func (t TimeOrOffset) Time() *time.Time

type UID

type UID []byte

func UIDListMerge added in v1.0.19

func UIDListMerge(list1 []UID, list2 []UID) []UID

Merge two lists of UIDs. Duplicates will be dropped. Not stably ordered.

func (UID) Bytes

func (u UID) Bytes() []byte

func (UID) Eq added in v1.0.19

func (u UID) Eq(other UID) bool

func (UID) String

func (u UID) String() string

type VersionArg

type VersionArg struct {
	Uid UID `codec:"uid" json:"uid"`
}

Jump to

Keyboard shortcuts

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