Documentation
¶
Index ¶
- Variables
- type AuthyClient
- type AuthyClientInterface
- type MockAuthyClient
- type NSQClient
- func (client *NSQClient) CreateChannel(topicName, channelName string) error
- func (client *NSQClient) CreateTopic(topicName string) error
- func (client *NSQClient) DeleteAllChannels() error
- func (client *NSQClient) DeleteAllTopics() error
- func (client *NSQClient) DeleteChannel(topicName, channelName string) error
- func (client *NSQClient) DeleteTopic(topicName string) error
- func (client *NSQClient) EmptyAllChannels() error
- func (client *NSQClient) EmptyAllTopics() error
- func (client *NSQClient) EmptyChannel(topicName, channelName string) error
- func (client *NSQClient) EmptyTopic(topicName string) error
- func (client *NSQClient) Enqueue(topic string, workItemID int64) error
- func (client *NSQClient) EnqueueString(topic string, data string) error
- func (client *NSQClient) GetInfo() (*NSQInfo, error)
- func (client *NSQClient) GetStats() (*NSQStatsData, error)
- func (client *NSQClient) PauseAllChannels() error
- func (client *NSQClient) PauseAllTopics() error
- func (client *NSQClient) PauseChannel(topicName, channelName string) error
- func (client *NSQClient) PauseTopic(topicName string) error
- func (client *NSQClient) UnpauseAllChannels() error
- func (client *NSQClient) UnpauseAllTopics() error
- func (client *NSQClient) UnpauseChannel(topicName, channelName string) error
- func (client *NSQClient) UnpauseTopic(topicName string) error
- type NSQInfo
- type NSQStatsData
- type RedisClient
- func (c *RedisClient) IngestObjectGet(workItemID int64, objIdentifier string) (string, error)
- func (c *RedisClient) KeyExists(workItemID int64) bool
- func (c *RedisClient) List(pattern string) ([]string, error)
- func (c *RedisClient) Ping() (string, error)
- func (c *RedisClient) RestorationObjectGet(workItemID int64, objIdentifier string) (string, error)
- func (c *RedisClient) SaveItem(workItemID int64, field, value string) error
- func (c *RedisClient) WorkItemDelete(workItemID int64) (int64, error)
- type SESClient
- type SNSClient
Constants ¶
This section is empty.
Variables ¶
var ErrAuthyDisabled = errors.New("authy is not enabled in this environment")
ErrAuthyDisabled means authy isn't enabled here. You can change that in the .env file.
Functions ¶
This section is empty.
Types ¶
type AuthyClient ¶
type AuthyClient struct {
// contains filtered or unexported fields
}
func (*AuthyClient) AwaitOneTouch ¶
func (ac *AuthyClient) AwaitOneTouch(userEmail, authyID string) (bool, error)
AwaitOneTouch sends a OneTouch login request via Authy and awaits the user's response. Param authyID is the user's AuthyID. Param userEmail is used for logging.
This is a blocking request that waits up to 45 seconds for a user to approve the one-touch push notification.
If request is approved, this returns true. Otherwise, false.
func (*AuthyClient) RegisterUser ¶
func (ac *AuthyClient) RegisterUser(userEmail string, countryCode int, phone string) (string, error)
RegisterUser registers a user with Authy for this app. Note that users need separate registrations for each environment (dev, demo, prod, etc.).
On success, this returns the user's new AuthyID. The caller is responsible for attaching that ID to the user object and saving it to the database.
Use user.CountryCodeAndPhone() to get country code and phone number, as these need to be separate. Do not pass user.PhoneNumber in format "+<country_code><number>" because that won't work.
type AuthyClientInterface ¶
type AuthyClientInterface interface { AwaitOneTouch(string, string) (bool, error) RegisterUser(string, int, string) (string, error) }
func NewAuthyClient ¶
func NewAuthyClient(authyEnabled bool, authyAPIKey string, log zerolog.Logger) AuthyClientInterface
func NewMockAuthyClient ¶
func NewMockAuthyClient() AuthyClientInterface
NewMockAuthyClient returns a mock authy client for testing.
type MockAuthyClient ¶
type MockAuthyClient struct{}
MockAuthyClient is used in testing.
func (*MockAuthyClient) AwaitOneTouch ¶
func (m *MockAuthyClient) AwaitOneTouch(userEmail, authyID string) (bool, error)
AwaitOneTouch for unit tests. Returns true unless param authyID == "fail".
func (*MockAuthyClient) RegisterUser ¶
func (m *MockAuthyClient) RegisterUser(userEmail string, countryCode int, phone string) (string, error)
RegisterUser for unit testing. Always succeeds.
type NSQClient ¶
type NSQClient struct { URL string // contains filtered or unexported fields }
func NewNSQClient ¶
NewNSQClient returns a new NSQ client that will connect to the NSQ server and the specified url. The URL is typically available through Config.NsqdHttpAddress, and usually ends with :4151. This is the URL to which we post items we want to queue, and from which our workers read.
Note that this client provides write access to queue, so we can add things. It does not provide read access. The workers do the reading.
func (*NSQClient) CreateChannel ¶
CreateChannel creates a channel in the specified topic. This is used only in testing.
func (*NSQClient) CreateTopic ¶
CreateTopic creates a topic. This is used only in testing.
func (*NSQClient) DeleteAllChannels ¶
DeleteAllChannels deletes all channels
func (*NSQClient) DeleteAllTopics ¶
DeleteAllTopics deletes all topics
func (*NSQClient) DeleteChannel ¶
DeleteChannel deletes a channel in the specified topic. This is used only in testing.
func (*NSQClient) DeleteTopic ¶
DeleteTopic deletes a topic. This is used only in testing.
func (*NSQClient) EmptyAllChannels ¶
EmptyAllChannels empties all channels.
func (*NSQClient) EmptyAllTopics ¶
EmptyAllTopics empties all topics.
func (*NSQClient) EmptyChannel ¶
EmptyChannel empties the specified channel.
func (*NSQClient) EmptyTopic ¶
EmptyTopic empties the specified topic.
func (*NSQClient) Enqueue ¶
Enqueue posts data to NSQ, which essentially means putting it into a work topic. Param topic is the topic under which you want to queue something. For example, prepare_topic, fixity_topic, etc. Param workItemId is the id of the WorkItem record in Pharos we want to queue.
func (*NSQClient) EnqueueString ¶
EnqueueString posts string data to the specified NSQ topic
func (*NSQClient) GetInfo ¶
GetInfo returns basic info about nsqd, including hostname and port numbers.
func (*NSQClient) GetStats ¶
func (client *NSQClient) GetStats() (*NSQStatsData, error)
GetStats allows us to get some basic stats from NSQ. The NSQ /stats endpoint returns a richer set of stats than what this fuction returns, but we only need some basic data for integration tests, so that's all we're parsing. The return value is a map whose key is the topic name and whose value is an NSQTopicStats object. NSQ is supposed to support topic_name as a query param, but this doesn't seem to be working in NSQ 0.3.0, so we're just returning stats for all topics right now. Also note that requests to /stats/ (with trailing slash) produce a 404.
func (*NSQClient) PauseAllChannels ¶
PauseAllChannels pauses all channels.
func (*NSQClient) PauseAllTopics ¶
PauseAllTopics pauses all topics.
func (*NSQClient) PauseChannel ¶
PauseChannel pauses the specified channel.
func (*NSQClient) PauseTopic ¶
PauseTopic pauses the topic with the specified name.
func (*NSQClient) UnpauseAllChannels ¶
UnpauseAllChannels unpauses all channels.
func (*NSQClient) UnpauseAllTopics ¶
UnpauseAllTopics unpauses all topics.
func (*NSQClient) UnpauseChannel ¶
UnpauseChannel unpauses the specified channel.
func (*NSQClient) UnpauseTopic ¶
UnpauseTopic unpauses the specified topic.
type NSQStatsData ¶
type NSQStatsData struct { Version string `json:"version"` Health string `json:"health"` StartTime uint64 `json:"start_time"` Topics []*nsqd.TopicStats `json:"topics"` Info *NSQInfo `json:"info"` }
NSQStatsData contains the important info returned by a call to NSQ's /stats endpoint, including the number of items in each topic and queue.
func (*NSQStatsData) GetChannel ¶
func (data *NSQStatsData) GetChannel(topicName, channelName string) *nsqd.ChannelStats
func (*NSQStatsData) GetTopic ¶
func (data *NSQStatsData) GetTopic(name string) *nsqd.TopicStats
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
RedisClient is a crude and deliberately limited implementation that returns JSON only. The JSON is intended for human consumption, primarily for APTrust admins to view when debugging problems.
The JSON represents internal state information from the ingest and restoration workers. The structure of the data may change over time, so this client simply uses map[string]interface{} structures to accomodate arbitrary JSON structures.
func NewRedisClient ¶
func NewRedisClient(address, password string, db int) *RedisClient
NewRedisClient creates a new RedisClient. Param address is the net address of the Redis server. Param password is the password required to connect. It may be blank, but shouldn't be in production. Param db is the id of the Redis database.
func (*RedisClient) IngestObjectGet ¶
func (c *RedisClient) IngestObjectGet(workItemID int64, objIdentifier string) (string, error)
IngestObjectGet returns a JSON string representing an ingest object and its associated work results.
func (*RedisClient) KeyExists ¶
func (c *RedisClient) KeyExists(workItemID int64) bool
KeyExists returns true if the specified key exists in our Redis DB.
func (*RedisClient) List ¶
func (c *RedisClient) List(pattern string) ([]string, error)
List returns up to the first 500 keys in the Redis DB matching the specified pattern. The 500 limit is to prevent overload if our Redis DB fills up with lots of entries.
Realistically, we will almost never have more than a few dozen keys at any given time, since Redis data is deleted as soon as processing completes. Each key is a WorkItem.ID in string form.
func (*RedisClient) Ping ¶
func (c *RedisClient) Ping() (string, error)
Ping pings the Redis server. It should return "PONG" if the server is running and we can connect.
func (*RedisClient) RestorationObjectGet ¶
func (c *RedisClient) RestorationObjectGet(workItemID int64, objIdentifier string) (string, error)
RestorationObjectGet returns a JSON string representing the specified restoration object.
func (*RedisClient) SaveItem ¶
func (c *RedisClient) SaveItem(workItemID int64, field, value string) error
SaveItem saves value to Redis. This is used only for testing.
func (*RedisClient) WorkItemDelete ¶
func (c *RedisClient) WorkItemDelete(workItemID int64) (int64, error)
WorkItemDelete deletes the Redis copy (NOT the Registry copy) of a WorkItem, along with its associated IngestObject and IngestFile records. This is dangerous and should be called only in two cases:
- We want to delete old ingest data from Redis after a failed ingest that we know we will never retry. This is essentially a cleanup operation.
- We are forcing an item back to the very first step of ingest or restoration, and we want the workers to redo all work from scratch instead of relying on the already completed work recorded in Redis. This is extremely rare, but it will come up a few times a year.
type SESClient ¶
type SESClient struct { FromAddress string ServiceEnabled bool Session *session.Session Service *ses.SES // contains filtered or unexported fields }