Skip to content

Commit

Permalink
commenting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Jan 22, 2024
1 parent 351bf4f commit 69bb881
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import "testing"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package authcmd

import (
"context"
Expand Down
3 changes: 2 additions & 1 deletion cmd/slackdump/internal/emoji/emojidl/emoji.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package emoji provides functions to dump the all slack emojis for a workspace.
// Package emojidl provides functions to dump the all slack emojis for a workspace.
// It skips the "alias" emojis, so only original an emoji with an original name
// is present. If you need to find the alias - lookup the index.json. The
// directory structure is the following:
Expand Down Expand Up @@ -48,6 +48,7 @@ func DlFS(ctx context.Context, sess emojidumper, fsa fsadapter.FS, failFast bool
if err != nil {
return fmt.Errorf("error during emoji dump: %w", err)
}

bIndex, err := json.Marshal(emojis)
if err != nil {
return fmt.Errorf("error marshalling emoji index: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/export/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func exportV3(ctx context.Context, sess *slackdump.Session, fsa fsadapter.FS, li
ctr := control.New(
chunkdir,
stream,
control.WithSubproc(fileproc.NewExport(params.ExportStorageType, sdl)),
control.WithFiler(fileproc.NewExport(params.ExportStorageType, sdl)),
control.WithLogger(lg),
control.WithFlags(flags),
control.WithTransformer(tf),
Expand Down
4 changes: 2 additions & 2 deletions cmd/slackdump/internal/format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/slack-go/slack"

"github.com/rusq/slackdump/v3"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/auth"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/authcmd"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/internal/cache"
Expand Down Expand Up @@ -240,7 +240,7 @@ func getUsers(ctx context.Context, dmp *dump, isOnline bool) ([]slack.User, erro
}

func getUsersOnline(ctx context.Context, cacheDir, wsp string) ([]slack.User, error) {
prov, err := auth.AuthCurrent(ctx, cacheDir, wsp)
prov, err := authcmd.AuthCurrent(ctx, cacheDir, wsp)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/slackdump/internal/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func RunRecord(ctx context.Context, cmd *base.Command, args []string) error {
defer stop()
// we are using the same file subprocessor as the mattermost export.
subproc := fileproc.NewExport(fileproc.STmattermost, dl)
ctrl := control.New(cd, stream, control.WithLogger(lg), control.WithSubproc(subproc))
ctrl := control.New(cd, stream, control.WithLogger(lg), control.WithFiler(subproc))
if err := ctrl.Run(ctx, list); err != nil {
base.SetExitStatus(base.SApplicationError)
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/slackdump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"golang.org/x/term"

"github.com/rusq/slackdump/v3/cmd/slackdump/internal/apiconfig"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/auth"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/authcmd"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/convertcmd"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/diag"
Expand Down Expand Up @@ -46,7 +46,7 @@ func init() {
convertcmd.CmdConvert,
list.CmdList,
emoji.CmdEmoji,
auth.CmdWorkspace,
authcmd.CmdWorkspace,
diag.CmdDiag,
apiconfig.CmdConfig,
format.CmdFormat,
Expand Down Expand Up @@ -178,7 +178,7 @@ func invoke(cmd *base.Command, args []string) error {
if cmd.RequireAuth {
trace.Logf(ctx, "invoke", "command %s requires auth", cmd.Name())
var err error
ctx, err = auth.AuthCurrentCtx(ctx, cfg.CacheDir(), cfg.Workspace)
ctx, err = authcmd.AuthCurrentCtx(ctx, cfg.CacheDir(), cfg.Workspace)
if err != nil {
trace.Logf(ctx, "invoke", "auth error: %s", err)
base.SetExitStatus(base.SAuthError)
Expand Down
2 changes: 1 addition & 1 deletion internal/chunk/chunktest/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (a *TestAuth) Test(ctx context.Context) error {
return a.WantTestError
}

// Client returns an authenticated HTTP client
// HTTPClient returns an authenticated HTTP client
func (a *TestAuth) HTTPClient() (*http.Client, error) {
return a.WantHTTPClient, a.WantHTTPClientErr
}
22 changes: 11 additions & 11 deletions internal/chunk/control/control.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package control hold the implmentation of the Slack Stream controller. It
// Package control hold 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
Expand Down Expand Up @@ -34,7 +34,7 @@ type Controller struct {
tf ExportTransformer
// files subprocessor, if not configured with options, it's a noop, as
// it's not necessary for all use cases.
subproc processor.Filer
filer processor.Filer
// lg is the logger
lg logger.Interface
// flags
Expand All @@ -44,10 +44,10 @@ type Controller struct {
// Option is a functional option for the Controller.
type Option func(*Controller)

// WithSubproc configures the controller with a file subprocessor.
func WithSubproc(f processor.Filer) Option {
// WithFiler configures the controller with a file subprocessor.
func WithFiler(f processor.Filer) Option {
return func(c *Controller) {
c.subproc = f
c.filer = f
}
}

Expand Down Expand Up @@ -79,11 +79,11 @@ func WithLogger(lg logger.Interface) Option {
// New creates a new [Controller].
func New(cd *chunk.Directory, s Streamer, opts ...Option) *Controller {
c := &Controller{
cd: cd,
s: s,
subproc: &noopFiler{},
tf: &noopTransformer{},
lg: logger.Default,
cd: cd,
s: s,
filer: &noopFiler{},
tf: &noopTransformer{},
lg: logger.Default,
}
for _, opt := range opts {
opt(c)
Expand Down Expand Up @@ -170,7 +170,7 @@ func (c *Controller) Run(ctx context.Context, list *structures.EntityList) error
}
// conversations goroutine
{
conv, err := dirproc.NewConversation(c.cd, c.subproc, c.tf)
conv, err := dirproc.NewConversation(c.cd, c.filer, c.tf)
if err != nil {
return fmt.Errorf("error initialising conversation processor: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/chunk/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"github.com/rusq/slackdump/v3/internal/osext"
)

// Recorder is a special Channeler that records all the data it receives, so
// that it can be replayed later.
// Recorder records all the data it receives, so that it can be replayed later.
type Recorder struct {
chunks chan Chunk
errC chan error
Expand All @@ -35,6 +34,7 @@ func WithEncoder(enc Encoder) Option {
}
}

// NewRecorder creates a new recorder.
func NewRecorder(w io.Writer, options ...Option) *Recorder {
filename := "unknown"
if f, ok := w.(osext.Namer); ok {
Expand Down
9 changes: 5 additions & 4 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Conversations interface {
Messenger
Filer
ChannelInformer

io.Closer
}

Expand All @@ -27,21 +28,21 @@ type ChannelInformer interface {

// Messenger is the interface that implements only the message fetching.
type Messenger interface {
// Messages is called for each message that is retrieved.
// Messages method is called for each message that is retrieved.
Messages(ctx context.Context, channelID string, numThreads int, isLast bool, messages []slack.Message) error
// ThreadMessages is called for each of the thread messages that are
// ThreadMessages method is called for each of the thread messages that are
// retrieved. The parent message is passed in as well.
ThreadMessages(ctx context.Context, channelID string, parent slack.Message, threadOnly, isLast bool, replies []slack.Message) error
}

type Filer interface {
// Files is called for each file that is retrieved. The parent message is
// Files method is called for each file that is retrieved. The parent message is
// passed in as well.
Files(ctx context.Context, channel *slack.Channel, parent slack.Message, ff []slack.File) error
}

type Users interface {
// Users is called for each user chunk that is retrieved.
// Users method is called for each user chunk that is retrieved.
Users(ctx context.Context, users []slack.User) error
}

Expand Down

0 comments on commit 69bb881

Please sign in to comment.