thread_mate

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package thread_mate here we define functions to help with platform mentions. For now, it covers only Slack syntax. In order to cover other platforms, we need to move it to the Botkube platform renderers and provide a common function that we can use in our message templating. For example,

body:
 plaintext: |
   Thanks for reaching out! Today, {{ .Assignee.ID | toMention }} will assist you in getting your Botkube up and running.

This way `toMention` function can be properly set per each platform.

Index

Constants

View Source
const (
	ThreadTypeOngoing  = "ongoing"
	ThreadTypeResolved = "resolved"
)

Variables

View Source
var (
	//go:embed config_schema.json
	ConfigJSONSchema string
)

Functions

This section is empty.

Types

type ActivityCmd

type ActivityCmd struct {
	AssigneeIDs string     `arg:"--assignee-ids"`
	Type        ThreadType `arg:"--thread-type"`
	PageIdx     int        `arg:"-p,--page"`
}

ActivityCmd represents the "activity" subcommand under the "get" command.

type Assignee

type Assignee struct {
	ID          string
	DisplayName string
}

Assignee represents a participant in a conversation.

type Commands

type Commands struct {
	Pick     *PickCmd     `arg:"subcommand:pick"`
	Get      *GetCmd      `arg:"subcommand:get"`
	Resolve  *ResolveCmd  `arg:"subcommand:resolve"`
	Takeover *TakeoverCmd `arg:"subcommand:takeover"`
	Export   *ExportCmd   `arg:"subcommand:export"`
}

Commands represents a collection of subcommands.

type Config

type Config struct {
	RoundRobin RoundRobinConfig `yaml:"roundRobin"`
	Logger     config.Logger    `yaml:"log"`
	Pick       PickConfig       `yaml:"pick"`

	Persistence PersistenceConfig `yaml:"persistence"`
}

Config holds the executor configuration.

func MergeConfigs

func MergeConfigs(configs []*executor.Config) (Config, error)

MergeConfigs merges the configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration parameters.

type ConfigMapDumper

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

ConfigMapDumper is a utility for working with Kubernetes ConfigMaps.

func NewConfigMapDumper

func NewConfigMapDumper(k8sCli kubernetes.Interface) *ConfigMapDumper

NewConfigMapDumper creates a new instance of ConfigMapDumper.

func (*ConfigMapDumper) Get

func (a *ConfigMapDumper) Get(namespace, name string) (string, error)

Get retrieves data from a ConfigMap in the specified namespace.

func (*ConfigMapDumper) SaveOrUpdate

func (a *ConfigMapDumper) SaveOrUpdate(namespace, name, data string) error

SaveOrUpdate saves or updates data in a ConfigMap in the specified namespace.

type ExportActivityCmd

type ExportActivityCmd struct {
	Type string `arg:"--type"`
}

ExportActivityCmd represents the options for the "export activity" subcommand.

type ExportCmd

type ExportCmd struct {
	Activity *ExportActivityCmd `arg:"subcommand:activity"`
}

ExportCmd represents the "export" subcommand.

type GetCmd

type GetCmd struct {
	Activity *ActivityCmd `arg:"subcommand:activity"`
}

GetCmd represents the "get" subcommand.

type PersistenceConfig

type PersistenceConfig struct {
	SyncInterval       time.Duration `yaml:"syncInterval"`
	ConfigMapNamespace string        `yaml:"configMapNamespace"`
}

type PickCmd

type PickCmd struct {
	MessageContext string `arg:"-m,--message"`
}

PickCmd represents the "pick" subcommand.

type PickConfig

type PickConfig struct {
	UserCooldownTime time.Duration `yaml:"userCooldownTime"`
	MessagesTemplate string        `yaml:"messagesTemplate"`
}

type ResolveCmd

type ResolveCmd struct {
	ID string `arg:"--id"`
}

ResolveCmd represents the "resolve" subcommand.

type RoundRobin

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

type RoundRobinConfig

type RoundRobinConfig struct {
	Assignees []string `yaml:"assignees"`
	GroupName string   `yaml:"groupName"`
}

type SystemData

type SystemData struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*SystemData) IsDirty

func (t *SystemData) IsDirty() bool

func (*SystemData) MarkDirty

func (t *SystemData) MarkDirty()

func (*SystemData) ResetDirty

func (t *SystemData) ResetDirty()

func (*SystemData) RoundRobinPickNext

func (t *SystemData) RoundRobinPickNext() uint32

type TakeoverCmd

type TakeoverCmd struct {
	ID string `arg:"--id"`
}

TakeoverCmd represents the "takeover" subcommand.

type Thread

type Thread struct {
	ID             string `csv:"-"`
	Assignee       Assignee
	MessageContext executor.Message `csv:"Message"`
	StartedAt      time.Time
	ResolvedBy     Assignee
}

Thread represents a conversation thread.

type ThreadMate

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

ThreadMate represents the main component for managing threads and interactions.

func New

func New(cfg Config, cfgDumper *ConfigMapDumper) *ThreadMate

New creates a new instance of ThreadMate.

func (*ThreadMate) Export

func (t *ThreadMate) Export(export *ExportCmd) api.Message

Export handles the "export" command.

func (*ThreadMate) GetActivity

func (t *ThreadMate) GetActivity(cmd *ActivityCmd, message executor.Message) api.Message

GetActivity handles the "get activity" command and retrieves thread activity.

func (*ThreadMate) GetSearchSection

func (t *ThreadMate) GetSearchSection(cmd *ActivityCmd, message executor.Message, selectedOpts []api.OptionItem, allOpts []api.OptionItem) api.Section

func (*ThreadMate) Pick

func (t *ThreadMate) Pick(cmd *PickCmd, msg executor.Message) ([]api.Message, error)

Pick handles the "pick" command and assigns a thread to an assignee.

func (*ThreadMate) Resolve

func (t *ThreadMate) Resolve(r *ResolveCmd, message executor.Message) api.Message

Resolve handles the "resolve" command and marks a thread as resolved.

func (*ThreadMate) Start

func (t *ThreadMate) Start()

Start starts the ThreadMate component.

func (*ThreadMate) Takeover

func (t *ThreadMate) Takeover(takeover *TakeoverCmd, message executor.Message) api.Message

Takeover handles the "takeover" command and allows an assignee to take over a thread.

type ThreadType

type ThreadType string

func (ThreadType) IsEmptyOrEqual

func (t ThreadType) IsEmptyOrEqual(exp ThreadType) bool

type Threads

type Threads struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Threads represents a collection of conversation threads.

func (*Threads) Append

func (t *Threads) Append(th Thread)

Append adds a new thread to the Threads collection.

func (*Threads) Delete

func (t *Threads) Delete(id string) *Thread

Delete removes a thread with the specified ID from the Threads collection.

func (*Threads) Get

func (t *Threads) Get() []Thread

Get returns a copy of the Threads collection.

func (*Threads) IsDirty

func (t *Threads) IsDirty() bool

IsDirty returns true if the Threads collection has been modified.

func (*Threads) Mutate

func (t *Threads) Mutate(id string, mutate func(th *Thread)) bool

Mutate applies a mutation function to a thread with the specified ID. If the thread is found, the mutation is applied, and the dirty flag is set to true.

func (*Threads) ResetDirty

func (t *Threads) ResetDirty()

ResetDirty resets the dirty flag to indicate that changes have been saved.

Jump to

Keyboard shortcuts

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