tracker

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package tracker connects immutable local issue identities to an opt-in Jira mirror. Local commits and remote mutations are separate, visible operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("Jira issue changed; refresh or reconcile before writing")
View Source
var ErrNotConfigured = errors.New("Jira tracker is not configured")
View Source
var ErrNotLinked = errors.New("issue has no Jira link")
View Source
var ErrPending = errors.New("Jira synchronization is pending")

Functions

func Enqueue

func Enqueue(ctx context.Context, tx *sql.Tx, id int64) error

Enqueue persists an outbound operation in the same transaction as a local mutation.

func ResolveKey

func ResolveKey(ctx context.Context, q queryer, project, key string) (string, error)

ResolveKey preserves exact local-key precedence and rejects ambiguous remote aliases.

func ResolveKeyByProjectID

func ResolveKeyByProjectID(ctx context.Context, q queryer, id int64, key string) (string, error)

Types

type Client

type Client interface {
	GetIssue(context.Context, string) (jira.Issue, error)
	CreateIssue(context.Context, jira.IssueFields) (jira.Issue, error)
	UpdateIssue(context.Context, string, map[string]any) error
	Transitions(context.Context, string) ([]jira.Transition, error)
	TransitionIssue(context.Context, string, string) error
	SearchByLabel(context.Context, string, string, string) (jira.SearchPage, error)
}

Client is the remote boundary, replaceable in disposable integration tests.

type Config

type Config struct {
	BaseURL         string                       `json:"baseURL"`
	Email           string                       `json:"email"`
	TokenIdentifier string                       `json:"tokenIdentifier"`
	RemoteProject   string                       `json:"remoteProject"`
	Types           map[string]string            `json:"types"`
	Priorities      map[string]string            `json:"priorities"`
	States          map[string]map[string]string `json:"states"`
	Enabled         bool                         `json:"enabled"`
}

Config contains provider metadata only, never credential values. Maps use Jira IDs.

type Link struct {
	LocalKey   string `json:"localKey"`
	RemoteID   string `json:"remoteId"`
	RemoteKey  string `json:"remoteKey"`
	URL        string `json:"url"`
	Baseline   string `json:"baseline"`
	SyncStatus string `json:"syncStatus"`
	LastError  string `json:"lastError,omitempty"`
}

func LinkFromDB

func LinkFromDB(ctx context.Context, db *sql.DB, id int64) (*Link, error)

type Plan

type Plan struct {
	Items []PlanItem `json:"items"`
}

type PlanItem

type PlanItem struct {
	Key      string `json:"key"`
	Revision int    `json:"revision"`
	Type     string `json:"type"`
	State    string `json:"state"`
	Action   string `json:"action"`
	Reason   string `json:"reason,omitempty"`
}

type Store

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

func Open

func Open(ctx context.Context, path string) (*Store, error)

func OpenReadOnly

func OpenReadOnly(ctx context.Context, path string) (*Store, error)

func WithDB

func WithDB(db *sql.DB, path string) *Store

WithDB shares an existing connection; the caller retains ownership.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Configuration

func (s *Store) Configuration(ctx context.Context, project string) (Config, error)

func (*Store) Configure

func (s *Store) Configure(ctx context.Context, project string, c Config) error

func (*Store) Disable

func (s *Store) Disable(ctx context.Context, project string) error

func (*Store) Enable

func (s *Store) Enable(ctx context.Context, project string) error

func (*Store) Flush

func (s *Store) Flush(ctx context.Context, project, key string) error

Flush explicitly attempts queued work, including while automatic routing is disabled.

func (*Store) FlushAutomatic added in v0.34.2

func (s *Store) FlushAutomatic(ctx context.Context, project, key string) error

FlushAutomatic sends queued work only while automatic routing is enabled. Disabled routing leaves existing intents and remote identities intact for explicit Flush, Migrate, or Reconcile operations.

func (*Store) Guard

func (s *Store) Guard(ctx context.Context, project, key string) error
func (s *Store) Link(ctx context.Context, project, key string) (Link, error)

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context, project string) ([]Link, error)

func (*Store) Plan

func (s *Store) Plan(ctx context.Context, project string) (Plan, error)

func (*Store) Reconcile

func (s *Store) Reconcile(ctx context.Context, project, key string) (Link, error)

func (*Store) ReconcileWithRetryIfAbsent added in v0.32.0

func (s *Store) ReconcileWithRetryIfAbsent(ctx context.Context, project, key string, retryIfAbsent bool) (Link, error)

func (*Store) Refresh

func (s *Store) Refresh(ctx context.Context, project, key string) (refreshed Link, refreshError error)

Refresh imports remote-owned fields. Contract/approval validation precedes local writes.

func (*Store) SetClientFactory

func (s *Store) SetClientFactory(factory func(context.Context, string, Config) (Client, error))

SetClientFactory is for embedding/tests; credentials remain managed by default.

func (*Store) Status

func (s *Store) Status(ctx context.Context, project string) ([]Link, error)

Jump to

Keyboard shortcuts

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