Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("transformer is closed")
Functions ¶
func ExportChanName ¶
ExportChanName returns the channel name, or the channel ID if it is a DM.
Types ¶
type COption ¶
type COption func(*Coordinator)
func WithIDChan ¶
WithIDChan allows to use an external ID channel.
type Converter ¶
type Converter interface { // Convert should convert the chunk to the Converters' output format. Convert(ctx context.Context, id chunk.FileID) error }
Converter is the interface that defines a set of methods for transforming chunks to some output format.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator coordinates the conversion of chunk files to the desired format. It is used to convert files in parallel.
func NewCoordinator ¶
func NewCoordinator(ctx context.Context, cvt Converter, opts ...COption) *Coordinator
NewCoordinator creates a new Coordinator.
type ExpConverter ¶
type ExpConverter struct {
// contains filtered or unexported fields
}
func NewExpConverter ¶
func NewExpConverter(cd *chunk.Directory, fsa fsadapter.FS, opt ...ExpCvtOption) *ExpConverter
func (*ExpConverter) Convert ¶
Convert is the chunk file export converter. It transforms the chunk file for the channel with ID into a slack export format. It expects the chunk file to be in the <srcdir>/<id>.json.gz file, and the attachments to be in the <srcdir>/<id> directory.
func (*ExpConverter) HasUsers ¶
func (t *ExpConverter) HasUsers() bool
func (*ExpConverter) SetUsers ¶
func (e *ExpConverter) SetUsers(users []slack.User)
func (*ExpConverter) WriteIndex ¶
func (t *ExpConverter) WriteIndex() error
WriteIndex generates and writes the export index files. It must be called once all transformations are done, because it might require to read channel files.
type ExpCvtOption ¶
type ExpCvtOption func(*ExpConverter)
func ExpWithMsgUpdateFunc ¶
func ExpWithUsers ¶
func ExpWithUsers(users []slack.User) ExpCvtOption
type ExpOption ¶
type ExpOption func(*ExportCoordinator)
ExpOption is a function that configures the Export instance.
func WithBufferSize ¶
WithBufferSize sets the size of the channel IDs buffer. This is the number of channel IDs that will be queued without blocking before the transform.Export is started.
type ExportCoordinator ¶
type ExportCoordinator struct {
// contains filtered or unexported fields
}
ExportCoordinator is a takes the chunks produced by the processor and transforms them into a Slack Export format. It is suitable for async processing, in which case, OnFinalise function is passed to the processor, the finalisation requests will be queued (up to a [bufferSz]) and will be processed once Start or StartWithUsers is called.
Please note, that transform requires users to be passed either through options or through StartWithUsers. If users are not passed, the ExportCoordinator.Start will return an error.
The asynchronous pattern to run the transform is as follows:
- Create the transform instance.
- Defer its Close method.
- In goroutine: Start user processing, and in the same goroutine, after all users are fetched, call ExportCoordinator.StartWithUsers, passing the fetched users slice.
- In another goroutine, start the ExportCoordinator Conversation processor, passing the transformer's OnFinalise function as the Finaliser option. It will be called by export processor for each channel that was completed.
func NewExportCoordinator ¶
func NewExportCoordinator(ctx context.Context, cvt UserConverter, tfopt ...ExpOption) *ExportCoordinator
NewExportCoordinator creates a new ExportCoordinator instance.
func (*ExportCoordinator) Close ¶
func (t *ExportCoordinator) Close() (err error)
Close closes the coordinator. It must be called once it is guaranteed that [Transform] will not be called anymore, otherwise the call to Transform will panic with "send on the closed channel". If the coordinator is already closed, it will return nil.
func (*ExportCoordinator) Start ¶
func (t *ExportCoordinator) Start(ctx context.Context) error
Start starts the coordinator, the users must have been initialised with the WithUsers option. Otherwise, use ExportCoordinator.StartWithUsers method. The function doesn't check if coordinator was already started or not.
func (*ExportCoordinator) StartWithUsers ¶
StartWithUsers starts the Transform processor with the provided list of users. Users are used to populate each message with the user profile, as per Slack original export format.
func (*ExportCoordinator) Transform ¶
Transform is the function that should be passed to the Channel processor. It will not block if the internal buffer is full. Buffer size can be set with the WithBufferSize option. The caller is allowed to call OnFinalise even if the processor is not started, in which case the channel ID will be queued for processing once the processor is started. If the export worker is closed, it will return ErrClosed.
type StdConverter ¶
type StdConverter struct {
// contains filtered or unexported fields
}
StdConverter is a converter of chunk files into the Slackdump format.
func NewStandard ¶
NewStandard creates a new standard dump converter.
type StdOption ¶
type StdOption func(*StdConverter)
func StdWithLogger ¶
func StdWithPipeline ¶
func StdWithPipeline(f ...func(channelID string, threadTS string, mm []slack.Message) error) StdOption
StdWithPipeline adds a pipeline function to the transformer, that will be called for each message slice, before it is written to the filesystem.
func StdWithTemplate ¶
type Templater ¶
type Templater interface {
Execute(c *types.Conversation) string
}