Documentation ¶
Overview ¶
Package slackdump is a generated GoMock package.
Index ¶
- Variables
- type Channeldeprecated
- type Channels
- type Conversation
- type Message
- type MockReporter
- type MockReporterMockRecorder
- type Option
- func DownloadFiles(b bool) Option
- func MaxUserCacheAge(d time.Duration) Option
- func NumWorkers(n int) Option
- func RetryDownloads(attempts int) Option
- func RetryThreads(attempts int) Option
- func Tier2Boost(eventsPerMin uint) Option
- func Tier2Burst(eventsPerSec uint) Option
- func Tier3Boost(eventsPerMin uint) Option
- func Tier3Burst(eventsPerSec uint) Option
- func UserCacheFilename(s string) Option
- type Options
- type Reporter
- type SlackDumper
- func (sd *SlackDumper) DumpMessages(ctx context.Context, channelID string) (*Conversation, error)
- func (sd *SlackDumper) DumpMessagesInTimeframe(ctx context.Context, channelID string, oldest, latest time.Time) (*Conversation, error)
- func (sd *SlackDumper) DumpThread(ctx context.Context, channelID, threadTS string) (*Conversation, error)
- func (sd *SlackDumper) DumpURL(ctx context.Context, slackURL string) (*Conversation, error)
- func (sd *SlackDumper) DumpURLInTimeframe(ctx context.Context, slackURL string, oldest, latest time.Time) (*Conversation, error)
- func (sd *SlackDumper) GetChannels(ctx context.Context, chanTypes ...string) (Channels, error)
- func (sd *SlackDumper) GetUsers(ctx context.Context) (Users, error)
- func (sd *SlackDumper) IsUserDeleted(id string) bool
- func (sd *SlackDumper) SaveFileTo(ctx context.Context, dir string, f *slack.File) (int64, error)
- func (sd *SlackDumper) SenderName(msg *Message) string
- type Users
Constants ¶
This section is empty.
Variables ¶
var DefOptions = Options{ DumpFiles: false, Workers: defNumWorkers, DownloadRetries: 3, Tier2Boost: 20, Tier2Burst: 1, Tier2Retries: 20, Tier3Boost: 120, Tier3Burst: 1, Tier3Retries: 3, ConversationsPerReq: 200, ChannelsPerReq: 100, UserCacheFilename: "users.json", MaxUserCacheAge: 4 * time.Hour, }
DefOptions is the default options used when initialising slackdump instance.
var ErrRetryFailed = errors.New("callback was not able to complete without errors within the allowed number of retries")
Functions ¶
This section is empty.
Types ¶
type Channel
deprecated
added in
v1.1.0
type Channel = Conversation
Channel keeps the slice of messages.
Deprecated: use Conversation instead.
type Conversation ¶ added in v1.3.0
type Conversation struct { Name string `json:"name"` Messages []Message `json:"messages"` // ID is the channel ID. ID string `json:"channel_id"` // ThreadTS is a thread timestamp. If it's not empty, it means that it's a // dump of a thread, not a channel. ThreadTS string `json:"thread_ts,omitempty"` }
Conversation keeps the slice of messages.
func (Conversation) IsThread ¶ added in v1.3.1
func (c Conversation) IsThread() bool
func (Conversation) String ¶ added in v1.3.0
func (c Conversation) String() string
func (Conversation) ToText ¶ added in v1.3.0
func (m Conversation) ToText(sd *SlackDumper, w io.Writer) (err error)
ToText outputs Messages m to io.Writer w in text format.
type Message ¶ added in v1.1.0
type Message struct { slack.Message ThreadReplies []Message `json:"slackdump_thread_replies,omitempty"` }
Message is the internal representation of message with thread.
type MockReporter ¶ added in v1.3.0
type MockReporter struct {
// contains filtered or unexported fields
}
MockReporter is a mock of Reporter interface.
func NewMockReporter ¶ added in v1.3.0
func NewMockReporter(ctrl *gomock.Controller) *MockReporter
NewMockReporter creates a new mock instance.
func (*MockReporter) EXPECT ¶ added in v1.3.0
func (m *MockReporter) EXPECT() *MockReporterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockReporter) ToText ¶ added in v1.3.0
func (m *MockReporter) ToText(sd *SlackDumper, w io.Writer) error
ToText mocks base method.
type MockReporterMockRecorder ¶ added in v1.3.0
type MockReporterMockRecorder struct {
// contains filtered or unexported fields
}
MockReporterMockRecorder is the mock recorder for MockReporter.
func (*MockReporterMockRecorder) ToText ¶ added in v1.3.0
func (mr *MockReporterMockRecorder) ToText(sd, w interface{}) *gomock.Call
ToText indicates an expected call of ToText.
type Option ¶ added in v1.1.0
type Option func(*Options)
Option is the signature of the option-setting function.
func DownloadFiles ¶ added in v1.3.0
DownloadFiles enables or disables the conversation/thread file downloads.
func MaxUserCacheAge ¶ added in v1.3.0
MaxUserCacheAge allows to set the maximum user cache age. If set to 0 - it will always use the API output, and never load cache.
func NumWorkers ¶ added in v1.1.1
NumWorkers allows to set the number of file download workers. n should be in range [1, NumCPU]. If not in range, will be reset to a defNumWorkers number, which seems reasonable.
func RetryDownloads ¶ added in v1.2.0
RetryDownloads sets the number of attempts to download a file when getting rate limited.
func RetryThreads ¶ added in v1.2.0
RetryThreads sets the number of attempts when dumping conversations and threads, and getting rate limited.
func Tier2Boost ¶ added in v1.3.1
Tier2Boost allows to deliver a magic kick to the limiter, to override the base slack tier limits. The resulting events per minute will be calculated like this:
events_per_sec = (<slack_tier_epm> + <eventsPerMin>) / 60.0
func Tier2Burst ¶ added in v1.3.1
Tier2Burst allows to set the limiter burst value.
func Tier3Boost ¶ added in v1.3.1
Tier3Boost allows to deliver a magic kick to the limiter, to override the base slack tier limits. The resulting events per minute will be calculated like this:
events_per_sec = (<slack_tier_epm> + <eventsPerMin>) / 60.0
func Tier3Burst ¶ added in v1.3.1
Tier3Burst allows to set the limiter burst value.
func UserCacheFilename ¶ added in v1.3.0
UserCacheFilename allows to set the user cache filename.
type Options ¶ added in v1.3.1
type Options struct { DumpFiles bool // will we save the conversation files? Workers int // number of file-saving workers DownloadRetries int // if we get rate limited on file downloads, this is how many times we're going to retry Tier2Boost uint // tier-2 limiter boost Tier2Burst uint // tier-2 limiter burst Tier2Retries int // tier-2 retries when getting 429 on channels fetch Tier3Boost uint // tier-3 limiter boost allows to increase or decrease the slack tier req/min rate. Affects all tiers. Tier3Burst uint // tier-3 limiter burst allows to set the limiter burst in req/sec. Default of 1 is safe. Tier3Retries int // number of retries to do when getting 429 on conversation fetch ConversationsPerReq int // number of messages we get per 1 API request. bigger the number, less requests, but they become more beefy. ChannelsPerReq int // number of channels to fetch per 1 API request. UserCacheFilename string // user cache filename MaxUserCacheAge time.Duration // how long the user cache is valid for. NoUserCache bool // sometimes slack disallows user access, so we need a way to overcome that. }
Options is the option set for the slackdumper.
type Reporter ¶
type Reporter interface {
ToText(sd *SlackDumper, w io.Writer) error
}
Reporter is an interface defining output functions
type SlackDumper ¶
type SlackDumper struct { // Users contains the list of users and populated on NewSlackDumper Users Users `json:"users"` UserIndex map[string]*slack.User `json:"-"` // contains filtered or unexported fields }
SlackDumper stores basic session parameters.
func New ¶
New creates new client and populates the internal cache of users and channels for lookups.
func NewWithOptions ¶ added in v1.3.1
func (*SlackDumper) DumpMessages ¶
func (sd *SlackDumper) DumpMessages(ctx context.Context, channelID string) (*Conversation, error)
DumpMessages fetches messages from the conversation identified by channelID.
func (*SlackDumper) DumpMessagesInTimeframe ¶ added in v1.3.1
func (sd *SlackDumper) DumpMessagesInTimeframe(ctx context.Context, channelID string, oldest, latest time.Time) (*Conversation, error)
DumpMessagesInTimeframe dumps messages in the given timeframe between oldest and latest. If oldest or latest are zero time, they will not be accounted for. Having both oldest and latest as zero time, will make this function behave similar to DumpMessages.
func (*SlackDumper) DumpThread ¶ added in v1.0.3
func (sd *SlackDumper) DumpThread(ctx context.Context, channelID, threadTS string) (*Conversation, error)
func (*SlackDumper) DumpURL ¶ added in v1.3.0
func (sd *SlackDumper) DumpURL(ctx context.Context, slackURL string) (*Conversation, error)
DumpURL dumps messages from the slack URL, it supports conversations and individual threads.
func (*SlackDumper) DumpURLInTimeframe ¶ added in v1.3.1
func (sd *SlackDumper) DumpURLInTimeframe(ctx context.Context, slackURL string, oldest, latest time.Time) (*Conversation, error)
func (*SlackDumper) GetChannels ¶
GetChannels list all conversations for a user. `chanTypes` specifies the type of messages to fetch. See github.com/rusq/slack docs for possible values
func (*SlackDumper) GetUsers ¶
func (sd *SlackDumper) GetUsers(ctx context.Context) (Users, error)
GetUsers retrieves all users either from cache or from the API.
func (*SlackDumper) IsUserDeleted ¶ added in v1.3.0
func (sd *SlackDumper) IsUserDeleted(id string) bool
IsUserDeleted checks if the user is deleted and returns appropriate value. It will assume user is not deleted, if it's not present in the user index.
func (*SlackDumper) SaveFileTo ¶
SaveFileTo saves a single file to the specified directory.
func (*SlackDumper) SenderName ¶ added in v1.3.0
func (sd *SlackDumper) SenderName(msg *Message) string
SenderName returns username for the message
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
mock_os
Package mock_os is a generated GoMock package.
|
Package mock_os is a generated GoMock package. |
tracer
Package tracer is simple convenience wrapper around writing trace to a file.
|
Package tracer is simple convenience wrapper around writing trace to a file. |