Documentation
¶
Overview ¶
Package model provides a general model for software projects. It includes types for content like issues and comments (Post), as well as types for other aspects of a project, like users and bots (Identity.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content interface { ID() string // universally unique ID, typically a URL Title_() string // empty if missing or not supported Body_() string // text content; some day, a sequence of multimedia elements // These are zero if unknown. CreatedAt_() time.Time UpdatedAt_() time.Time }
A Content is a piece of meaningful information. It may be a name, an email address, or an entire document. TODO: remove trailing underscores after renaming conflicting fields elsewhere.
type Identity ¶
type Identity struct { Realm Realm ID string // unique for the realm Name string // non-canonical display name, if known (e.g. "Pat Brown", "The Go Team") }
An Identity is an entity that can interact with a project. It contains a unique identifier for a person, team or bot.
type Post ¶
type Post interface { Content Project() string // ID of project this belongs to Author() *Identity // nil if unknown or not supported CanEdit() bool // can the content or metadata of this post be modified? CanHaveChildren() bool // can this kind of Post have children? ParentID() string // the parent post's ID, empty if this is a root post Updates() PostUpdates // set changes on a PostUpdates, then pass to [Source.Update] }
A Post is a piece of content that can be easily made public ("posted"). Examples are email messages, blog posts, and issue comments.
A Post may have children.
type PostUpdates ¶
type PostUpdates interface { SetTitle(string) error // set the title SetBody(string) error // set the body }
PostUpdates holds updates to a Post.
type Source ¶
type Source[T Content] interface { // A unique name for the source. For example, "GitHubIssues". Name() string // Download the current value for the ID from the external source. Read(ctx context.Context, id string) (T, error) // Update c by applying the given Updates. // Updates should describe how to modify c in a form that the Source // understands. For a [Post], call [Post.Update] to obtain such a value. Update(ctx context.Context, c T, u Updates) error // Create a new instance of T in the source, returning its unique ID. Create(context.Context, T) (id string, err error) // Delete the item with the given ID. // No error is returned if the ID is not found. // An error is returned if deletion is not unsupported or the item cannot be deleted. Delete(_ context.Context, id string) error }
A Source allows direct access to an external system, or a part of a system.