control

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

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

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

Documentation

Overview

Package control holds the implementation of the Slack Stream controller. It runs the API scraping in several goroutines and manages the data flow between them. It records the output of the API scraper into a chunk directory. It also manages the transformation of the data, if the caller is interested in it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller is the main controller of the Slack Stream. It runs the API scraping in several goroutines and manages the data flow between them.

func New

func New(cd *chunk.Directory, s Streamer, opts ...Option) *Controller

New creates a new Controller.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context, list *structures.EntityList) error

func (*Controller) SearchAll

func (s *Controller) SearchAll(ctx context.Context, query string) error

func (*Controller) SearchFiles

func (s *Controller) SearchFiles(ctx context.Context, query string) error

func (*Controller) SearchMessages

func (s *Controller) SearchMessages(ctx context.Context, query string) error

type Error

type Error struct {
	// Subroutine is the name of the subroutine that failed.
	Subroutine string
	// Stage is the stage of the subroutine that failed.
	Stage string
	// Err is the error that caused the failure.
	Err error
}

Error is a controller error.

func (Error) Error

func (e Error) Error() string

type ExportTransformer

type ExportTransformer interface {
	dirproc.Transformer
	TransformStarter
}

ExportTransformer is a transformer that can be started with a list of users. The compound nature of this interface is called by the asynchronous nature of execution and the fact that we need to start the transformer after Users goroutine is done, which can happen any time after the Run has started.

type Flags

type Flags struct {
	MemberOnly bool
}

Flags are the controller flags.

type Option

type Option func(*Controller)

Option is a functional option for the Controller.

func WithFiler

func WithFiler(f processor.Filer) Option

WithFiler configures the controller with a file subprocessor.

func WithFlags

func WithFlags(f Flags) Option

WithFlags configures the controller with flags.

func WithLogger

func WithLogger(lg *slog.Logger) Option

WithLogger configures the controller with a logger.

func WithTransformer

func WithTransformer(tf ExportTransformer) Option

WithTransformer configures the controller with a transformer.

type Streamer

type Streamer interface {
	Conversations(ctx context.Context, proc processor.Conversations, links <-chan string) error
	ListChannels(ctx context.Context, proc processor.Channels, p *slack.GetConversationsParameters) error
	Users(ctx context.Context, proc processor.Users, opt ...slack.GetUsersOption) error
	WorkspaceInfo(ctx context.Context, proc processor.WorkspaceInfo) error
	SearchMessages(ctx context.Context, proc processor.MessageSearcher, query string) error
	SearchFiles(ctx context.Context, proc processor.FileSearcher, query string) error
}

Streamer is the interface for the API scraper.

type TransformStarter

type TransformStarter interface {
	StartWithUsers(ctx context.Context, users []slack.User) error
}

Jump to

Keyboard shortcuts

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