Documentation
¶
Index ¶
Constants ¶
const PlatformID = "linear"
PlatformID is the platform identifier used in SessionKey and ingest routing.
Variables ¶
This section is empty.
Functions ¶
func NewPlatform ¶
NewPlatform constructs a Linear platform from configuration. Persistent state (seen_issues.ndjson, seen_comments.ndjson) lives in ~/.openbee/.linear/.
Types ¶
type Client ¶
type Client interface {
Viewer(ctx context.Context) (User, error)
// IssuesInStates returns every issue whose state.name is in `states`,
// carrying label `label`, and belonging to one of the given `projects`.
// Empty `states` or `projects` is rejected by policy at the platform layer.
// The returned slice contains all pages materialized in chronological
// (createdAt-ascending) order.
IssuesInStates(ctx context.Context, states []string, label string, projects []string) ([]Issue, error)
CreateComment(ctx context.Context, issueID, body string, parentID *string) (Comment, error)
// DownloadAsset fetches a uploads.linear.app asset using the workspace API
// key in the Authorization header. Returns the body and the server-reported
// Content-Type. A non-2xx response or body larger than maxBytes is returned
// as an error. maxBytes <= 0 disables the size limit.
DownloadAsset(ctx context.Context, url string, maxBytes int) (data []byte, contentType string, err error)
// FileUpload runs Linear's fileUpload mutation and returns the presigned
// upload target plus the asset URL to embed in a comment markdown.
FileUpload(ctx context.Context, name, mime string, size int) (FileUploadTicket, error)
// CreateReaction adds a reaction to the given target with the given emoji
// shortcode (e.g. ":eyes:") and returns the new reaction's ID.
CreateReaction(ctx context.Context, target ReactionTarget, emoji string) (string, error)
}
Client is the Linear GraphQL client surface used by the receiver and sender. Tests substitute a fake.
type Comment ¶
type Comment struct {
ID string `json:"id"`
Body string `json:"body"`
CreatedAt time.Time `json:"createdAt"`
User User `json:"user"`
ParentID *string `json:"parentId"`
}
Comment is the subset of Linear's Comment type we care about.
type FileUploadTicket ¶
FileUploadTicket is the result of Linear's fileUpload mutation. AssetURL is embedded into a comment markdown after the bytes are PUT to UploadURL with the supplied Headers.
type Issue ¶
type Issue struct {
ID string `json:"id"`
Identifier string `json:"identifier"` // e.g. "ENG-42"
Title string `json:"title"`
Description string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Team Team `json:"team"`
Creator User `json:"creator"`
Project *Project `json:"project,omitempty"` // nil when issue has no project
Comments []Comment `json:"-"` // unwrapped from comments.nodes
}
Issue is the subset of Linear's Issue type we care about.
type LinearPlatform ¶
type LinearPlatform struct {
// contains filtered or unexported fields
}
LinearPlatform implements platform.Platform.
func (*LinearPlatform) ID ¶
func (p *LinearPlatform) ID() string
func (*LinearPlatform) Receiver ¶
func (p *LinearPlatform) Receiver() platform.PlatformReceiverAdapter
func (*LinearPlatform) Sender ¶
func (p *LinearPlatform) Sender() platform.PlatformSenderAdapter
type LinearReceiver ¶
type LinearReceiver struct {
// contains filtered or unexported fields
}
LinearReceiver polls Linear for issue/comment updates by workflow-state.
func (*LinearReceiver) Start ¶
func (r *LinearReceiver) Start(ctx context.Context, dispatch func(platform.InboundMessage)) error
Start runs the polling loop until ctx is cancelled.
type LinearSender ¶
type LinearSender struct {
// contains filtered or unexported fields
}
LinearSender posts replies as Linear comments.
func (*LinearSender) Send ¶
func (s *LinearSender) Send(ctx context.Context, msg platform.OutboundMessage) error
type ReactionTarget ¶
ReactionTarget identifies what to react on. Exactly one of CommentID or IssueID must be non-empty; CommentID takes precedence when both are set.
type SeenSet ¶
type SeenSet struct {
// contains filtered or unexported fields
}
SeenSet persists a grow-only set of already-dispatched IDs to <dir>/<filename> as NDJSON (one ID per line). Add is append-only. Not safe for concurrent use; expected to be driven by a single goroutine.
func NewSeenSet ¶
NewSeenSet constructs a SeenSet that persists to <dir>/<filename>. Call Load before using Contains or Add.
func (*SeenSet) Add ¶
Add records ids as dispatched and appends only the previously-unseen IDs to the on-disk NDJSON file. Empty input and fully-duplicate input are no-ops. The in-memory set is updated only after the write succeeds, so a write failure leaves memory and disk in sync.