connector

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package connector pulls raw records from work sources and normalizes them into records the indexer merges into the expertise graph.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCodeOwners = errors.New("codeowners: no CODEOWNERS file found")

ErrNoCodeOwners indicates no CODEOWNERS file was found.

View Source
var ErrNoColumns = errors.New("org csv: required columns missing")

ErrNoColumns indicates required columns were absent from the header.

View Source
var ErrNoHeader = errors.New("org csv: missing header row")

ErrNoHeader indicates the CSV had no header row.

View Source
var ErrNoRepoPaths = errors.New("git: no repository paths")

ErrNoRepoPaths indicates no repository paths were given to the git connector.

View Source
var ErrNoRepos = errors.New("github: no repositories (use repos or an org)")

ErrNoRepos indicates no repositories were given to the GitHub connector.

Functions

This section is empty.

Types

type CodeOwners

type CodeOwners struct {
	// Path is a CODEOWNERS file or a repo root to search for one.
	Path string
}

CodeOwners is a Source that reads a CODEOWNERS file and maps each owner to the topics implied by the paths they own. It answers "who owns this system".

func NewCodeOwners

func NewCodeOwners(path string) *CodeOwners

NewCodeOwners returns a CodeOwners source for path.

func (*CodeOwners) Fetch

func (c *CodeOwners) Fetch(ctx context.Context) ([]Record, error)

Fetch finds and parses the CODEOWNERS file, returning one record per owner.

type Confluence added in v0.1.4

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

Confluence is a Source that ingests pages and weights their creator and last editor by the labels, title words, and space of the pages they wrote.

func NewConfluence added in v0.1.4

func NewConfluence(siteURL, email, token string, opts ConfluenceOptions) *Confluence

NewConfluence returns a Confluence connector for the site, authenticating with an email and API token.

func NewConfluenceWithClient added in v0.1.4

func NewConfluenceWithClient(client *confluence.Client, opts ConfluenceOptions) *Confluence

NewConfluenceWithClient returns a Confluence connector using a preconfigured client. Tests use it to inject a client pointed at a mock server.

func (*Confluence) Fetch added in v0.1.4

func (c *Confluence) Fetch(ctx context.Context) ([]Record, error)

Fetch searches pages and returns one record per person, weighted by topic.

type ConfluenceOptions added in v0.1.4

type ConfluenceOptions struct {
	// Spaces scopes the search to these space keys.
	Spaces []string
	// CQL overrides the query entirely when set.
	CQL string
	// MaxPages caps pages read; zero uses a default.
	MaxPages int
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

ConfluenceOptions configures the Confluence connector.

type GitHistory added in v0.1.9

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

GitHistory is a Source that mines commit authors per changed path, so the people doing the work on a system surface even when nothing declares ownership. Authors join other sources by commit email.

func NewGitHistory added in v0.1.9

func NewGitHistory(opts GitOptions) *GitHistory

NewGitHistory returns a git history source over the given repositories.

func (*GitHistory) Fetch added in v0.1.9

func (g *GitHistory) Fetch(ctx context.Context) ([]Record, error)

Fetch reads each repository's recent history and returns one record per author, weighted by how often they touched each topic.

type GitHub

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

GitHub is a Source that ingests repositories. It weights people by what they actually work on: pull request and issue labels and titles for authors, reviewers, and assignees, plus repository topics for contributors and CODEOWNERS for path ownership.

func NewGitHub

func NewGitHub(token string, opts GitHubOptions) *GitHub

NewGitHub returns a GitHub connector authenticating with token.

func NewGitHubWithClient

func NewGitHubWithClient(client *github.Client, opts GitHubOptions) *GitHub

NewGitHubWithClient returns a GitHub connector using a preconfigured client. Tests use it to inject a client pointed at a mock server.

func (*GitHub) Fetch

func (g *GitHub) Fetch(ctx context.Context) ([]Record, error)

Fetch reads each repository and returns person records weighted by topic.

type GitHubOptions

type GitHubOptions struct {
	// Repos is a list of "owner/name" repositories to index.
	Repos []string
	// Org, when set, adds the org's repositories.
	Org string
	// MaxRepos caps repositories taken from the org; zero means all returned.
	MaxRepos int
	// ResolveEmails fetches each user's profile to join by email.
	ResolveEmails bool
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

GitHubOptions configures the GitHub connector.

type GitOptions added in v0.1.9

type GitOptions struct {
	// Paths are local repository roots to read.
	Paths []string
	// SinceDays bounds how far back to read history; zero means one year.
	SinceDays int
	// MaxCommits caps commits read per repository; zero means 2000.
	MaxCommits int
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

GitOptions configures the git history connector.

type Jira

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

Jira is a Source that ingests issues and weights the assignee and reporter by the components, labels, summary words, and project of the issues they handle.

func NewJira

func NewJira(baseURL, email, token string, opts JiraOptions) *Jira

NewJira returns a Jira connector for the site, authenticating with an email and API token.

func NewJiraWithClient

func NewJiraWithClient(client *jira.Client, opts JiraOptions) *Jira

NewJiraWithClient returns a Jira connector using a preconfigured client. Tests use it to inject a client pointed at a mock server.

func (*Jira) Fetch

func (j *Jira) Fetch(ctx context.Context) ([]Record, error)

Fetch searches issues and returns one record per person, weighted by topic.

type JiraOptions

type JiraOptions struct {
	// Projects scopes the search to these project keys.
	Projects []string
	// JQL overrides the query entirely when set.
	JQL string
	// MaxIssues caps issues read; zero uses a default.
	MaxIssues int
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

JiraOptions configures the Jira connector.

type Kind

type Kind int

Kind classifies a record. For KindChannel records the person identity fields are unused: Name is the channel name, Title is the channel topic, Text is the purpose and sampled message text mined for affinity, and Members lists the person references active in the channel.

const (
	// KindPerson describes a person. It is the zero value.
	KindPerson Kind = iota
	// KindChannel describes a channel, a place to ask.
	KindChannel
)

type OrgCSV

type OrgCSV struct {
	// Path is the CSV file path.
	Path string
	// TopicSep splits the topics column into individual topics; default ";".
	TopicSep string
}

OrgCSV is a Source that reads an organization chart from a CSV file. The header row is matched case-insensitively against known column names, so column order and exact spelling do not matter.

func NewOrgCSV

func NewOrgCSV(path string) *OrgCSV

NewOrgCSV returns an OrgCSV reading the file at path with default settings.

func (*OrgCSV) Fetch

func (o *OrgCSV) Fetch(ctx context.Context) ([]Record, error)

Fetch reads the CSV and returns one record per non-empty data row.

type PagerDuty added in v0.1.5

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

PagerDuty is a Source that ingests services and on-call assignments, giving each on-call person the topics of the services they answer for.

func NewPagerDuty added in v0.1.5

func NewPagerDuty(token string, opts PagerDutyOptions) *PagerDuty

NewPagerDuty returns a PagerDuty connector authenticating with token.

func NewPagerDutyWithClient added in v0.1.5

func NewPagerDutyWithClient(client *pagerduty.Client, opts PagerDutyOptions) *PagerDuty

NewPagerDutyWithClient returns a PagerDuty connector using a preconfigured client. Tests use it to inject a client pointed at a mock server.

func (*PagerDuty) Fetch added in v0.1.5

func (p *PagerDuty) Fetch(ctx context.Context) ([]Record, error)

Fetch reads services and on-call assignments, returning one record per person weighted by the topics of the services they are on call for.

type PagerDutyOptions added in v0.1.5

type PagerDutyOptions struct {
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

PagerDutyOptions configures the PagerDuty connector.

type Record

type Record struct {
	// Kind classifies the record; the zero value is KindPerson.
	Kind Kind
	// PersonID is a stable per-source identifier; empty derives one from email.
	PersonID string
	// Name is the person's display name.
	Name string
	// Email is the person's work email.
	Email string
	// Title is the person's job title.
	Title string
	// Team is the person's team name.
	Team string
	// Org is the person's organization name.
	Org string
	// Manager is the manager's email or identifier, if known.
	Manager string
	// Topics are explicit expertise tags for the person or channel.
	Topics []string
	// Members lists person references active in a KindChannel record.
	Members []string
	// Text is free-form text attributed to the person or channel, mined for topics.
	Text string
	// Source names the origin connector, e.g. "org-csv".
	Source string
	// Weight scales this record's affinity contribution; zero means one.
	Weight float64
	// Time is when the described activity happened. The zero value marks the
	// record as a current fact that never decays.
	Time time.Time
}

Record is one normalized observation from a source. A KindPerson record describes a person: identity, org placement, topics, and mined text. A KindChannel record describes a place to ask, with the channel name, topic, text, and active members.

type Slack

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

Slack is a Source that ingests workspace users, channels, and recent history.

func NewSlack

func NewSlack(token string, opts SlackOptions) *Slack

NewSlack returns a Slack connector authenticating with token.

func NewSlackWithClient

func NewSlackWithClient(client *slack.Client, opts SlackOptions) *Slack

NewSlackWithClient returns a Slack connector using a preconfigured client. Tests use it to inject a client pointed at a mock server.

func (*Slack) Fetch

func (s *Slack) Fetch(ctx context.Context) ([]Record, error)

Fetch reads users, channels, and bounded history, returning person and channel records. Person identity joins other sources by email.

type SlackOptions

type SlackOptions struct {
	// IncludePrivate also ingests private channels the token can read.
	IncludePrivate bool
	// SinceDays bounds history age; zero uses the default.
	SinceDays int
	// MaxMessages caps messages per channel; zero uses the default.
	MaxMessages int
	// MaxChannels caps channels processed; zero means all.
	MaxChannels int
	// Log receives progress lines; nil discards them.
	Log io.Writer
}

SlackOptions configures the Slack connector.

type Source

type Source interface {
	// Fetch returns the records this source currently provides.
	Fetch(ctx context.Context) ([]Record, error)
}

Source fetches and normalizes records from one origin.

type SourceFunc

type SourceFunc func(ctx context.Context) ([]Record, error)

SourceFunc adapts a function to the Source interface.

func (SourceFunc) Fetch

func (f SourceFunc) Fetch(ctx context.Context) ([]Record, error)

Fetch calls f.

Jump to

Keyboard shortcuts

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