dirproc

package
v3.0.0-pre-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dirproc is a processor that writes the data into gzipped files in a directory. Each conversation is output to a separate gzipped JSONL file. If a thread is given, the filename will have the thread ID in it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channels

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

Channels is a processor that writes the channel information into the channels file.

func NewChannels

func NewChannels(dir *chunk.Directory, fn func(c []slack.Channel) error) (*Channels, error)

NewChannels creates a new Channels processor. fn is called for each channel chunk that is retrieved. The function is called before the chunk is processed by the recorder.

func (*Channels) Channels

func (cp *Channels) Channels(ctx context.Context, channels []slack.Channel) error

Channels is called for each channel chunk that is retrieved. Then, the function calls the function passed in to the constructor for the channel slice.

func (Channels) Close

func (p Channels) Close() error

Close closes the processor and the underlying chunk file.

type ConvOption

type ConvOption func(*Conversations)

ConvOption is a function that configures the Conversations processor.

func WithLogger

func WithLogger(lg *slog.Logger) ConvOption

WithLogger sets the logger for the processor.

func WithRecordFiles

func WithRecordFiles(b bool) ConvOption

WithRecordFiles sets whether the files should be recorded in the chunk file.

type Conversations

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

Conversations is a processor that writes the channel and thread messages. Zero value is unusable. Use NewConversation to create a new instance.

func NewConversation

func NewConversation(cd *chunk.Directory, filesSubproc processor.Filer, tf Transformer, opts ...ConvOption) (*Conversations, error)

NewConversation returns the new conversation processor. filesSubproc will be called for each file chunk, tf will be called for each completed channel or thread, when the reference count becomes zero. Reference count is increased with each call to Channel processing functions.

func (*Conversations) ChannelInfo

func (cv *Conversations) ChannelInfo(ctx context.Context, ci *slack.Channel, threadTS string) error

ChannelInfo is called for each channel that is retrieved.

func (*Conversations) ChannelUsers

func (cv *Conversations) ChannelUsers(ctx context.Context, channelID string, threadTS string, cu []string) error

func (*Conversations) Close

func (cv *Conversations) Close() error

func (*Conversations) Files

func (cv *Conversations) Files(ctx context.Context, channel *slack.Channel, parent slack.Message, ff []slack.File) error

Files is called for each file that is retrieved. The parent message is passed in as well.

func (*Conversations) Messages

func (cv *Conversations) Messages(ctx context.Context, channelID string, numThreads int, isLast bool, mm []slack.Message) error

Messages is called for each message that is retrieved.

func (*Conversations) ThreadMessages

func (cv *Conversations) ThreadMessages(ctx context.Context, channelID string, parent slack.Message, threadOnly bool, isLast bool, tm []slack.Message) error

ThreadMessages is called for each of the thread messages that are retrieved. The parent message is passed in as well.

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

Search is the search results directory processor. The results are written to "search.json.gz" file in the chunk directory.

func NewSearch

func NewSearch(dir *chunk.Directory, filer processor.Filer) (*Search, error)

NewSearch creates a new search processor.

func (Search) Close

func (p Search) Close() error

Close closes the processor and the underlying chunk file.

func (*Search) Files

func (s *Search) Files(ctx context.Context, channel *slack.Channel, parent slack.Message, ff []slack.File) error

type Transformer

type Transformer interface {
	// Transform is the function that starts the tranformation of the channel
	// or thread with the given id.  It is called  when the reference count
	// for the channel id becomes zero (meaning, that there are no more chunks
	// to process).  It should return [transform.ErrClosed] if the transformer
	// is closed.
	Transform(ctx context.Context, id chunk.FileID) error
}

Transformer is an interface that is called when the processor is finished processing a channel or thread.

type UserOption

type UserOption func(*Users)

func WithUsers

func WithUsers(cb func([]slack.User) error) UserOption

WithUsers sets the users callback.

type Users

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

Users is a users processor, writes users into the users.json.gz file.

func NewUsers

func NewUsers(cd *chunk.Directory, opt ...UserOption) (*Users, error)

NewUsers creates a new Users processor.

func (Users) Close

func (p Users) Close() error

Close closes the processor and the underlying chunk file.

func (*Users) Users

func (u *Users) Users(ctx context.Context, users []slack.User) error

Users processes chunk of users. If the callback is set, it will be called with the users slice.

type Workspace

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

Workspace is a processor that writes the workspace information into the workspace file.

func NewWorkspace

func NewWorkspace(cd *chunk.Directory) (*Workspace, error)

NewWorkspace creates a new workspace processor.

func (Workspace) Close

func (p Workspace) Close() error

Close closes the processor and the underlying chunk file.

Jump to

Keyboard shortcuts

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