Documentation ¶
Overview ¶
Package googlegroups saves google group conversations as HTML in a storage.DB. Every Google Group has a unique name. Group conversations are identified with a URL of the form https://groups.google.com/g/<group name>/c/<conversation id>. The URL points to the Google Group web page for the conversation. The page contains all individual conversation messages.
Index ¶
- Constants
- type Client
- func (c *Client) Add(group string) error
- func (c *Client) ConversationWatcher(name string) *timed.Watcher[*ConversationEvent]
- func (c *Client) Conversations(group string) iter.Seq2[string, func() *Conversation]
- func (c *Client) DocWatcher() *timed.Watcher[*ConversationEvent]
- func (c *Client) RequestFlush()
- func (c *Client) Sync(ctx context.Context) error
- func (c *Client) SyncGroup(ctx context.Context, group string) (err error)
- func (c *Client) Testing() *TestingClient
- func (c *Client) ToDocs(ce *ConversationEvent) (iter.Seq[*docs.Doc], bool)
- type Conversation
- type ConversationEvent
- type TestingClient
Constants ¶
const DocWatcherID = "ggroupsrelateddocs"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a connection to google groups, and to the database that stores information gathered from the groups.
func New ¶
New returns a new client to access google groups. The client uses the given logger, databases, and HTTP client.
The secret database will look for a secret whose name is the "googlegroups" instance. The value will be user:pass. This is not yet used.
func (*Client) Add ¶
Add adds a google group such as "golang-dev" to the database. It only adds the group sync metadata. The initial data fetch does not happen until [Sync] or [SyncGroup] is called. If the group is already present, Add does nothing and returns nil.
func (*Client) ConversationWatcher ¶
func (c *Client) ConversationWatcher(name string) *timed.Watcher[*ConversationEvent]
ConversationWatcher returns a new timed.Watcher with the given name. It picks up where any previous Watcher of the same name left off.
func (*Client) Conversations ¶
Conversations returns an iterator over the group conversations. The first iterator value is the conversation URL. The second iterator value is a function that can be called to return information about the conversation, as with storage.DB.Scan.
func (*Client) DocWatcher ¶
func (c *Client) DocWatcher() *timed.Watcher[*ConversationEvent]
DocWatcher returns the change event watcher with name "ggroupsrelateddocs". Implements docs.Source.DocWatcher.
func (*Client) RequestFlush ¶
func (c *Client) RequestFlush()
RequestFlush asks sync to flush the database to disk when convenient. This may be called concurrently with Client.Sync.
func (*Client) Testing ¶
func (c *Client) Testing() *TestingClient
Testing returns a TestingClient, which provides access to Client functionality intended for testing. Testing only returns a non-nil TestingClient in testing mode, which is active if the current program is a test binary (that is, testing.Testing returns true). Otherwise, Testing returns nil.
Each Client has only one TestingClient associated with it. Every call to Testing returns the same TestingClient.
func (*Client) ToDocs ¶
ToDocs converts a ConversationEvent to an embeddable document (wrapped as an iterator).
This document consists of the HTML for the first message of a Google Group conversation.
https://groups.google.com/g/<group>/c/<conversation>
ToDocs returns (nil, false) if any of the necessary data cannot be found in the client's db.
Implements docs.Source.ToDocs.
type Conversation ¶
type Conversation struct { // Group name. Group string // Title of the conversation. Title string // URL points to the Google Groups web // page of the conversation. The page // contains conversation messages. URL string // Messages are raw HTML data that contain // individual conversation messages obtained // from URL. Messages []string // contains filtered or unexported fields }
Conversation is a Google Group conversation represented by HTML from Google Groups web page.
type ConversationEvent ¶
type ConversationEvent struct { DBTime timed.DBTime // time of the change Group string // group name URL string // group URL }
A ConversationEvent is a Google Groups conversation change event returned by Conversationatcher.
func (*ConversationEvent) LastWritten ¶
func (ce *ConversationEvent) LastWritten() timed.DBTime
LastWritten implements docs.Entry.LastWritten.
type TestingClient ¶
type TestingClient struct {
// contains filtered or unexported fields
}
A TestingClient provides access to Client functionality intended for testing.
func (*TestingClient) LoadTxtar ¶
func (tc *TestingClient) LoadTxtar(file string) error
LoadTxtar loads a conversation info history from the named txtar file, and adds it to tc.convs.
The file should contain a txtar archive (see golang.org/x/tools/txtar). Each file in the archive may be named “conversation #n” (for example “conversation#1”). A line in the file must be in the format "key: value", where "key" is one of the fields of Conversation type.
func (*TestingClient) LoadTxtarData ¶
func (tc *TestingClient) LoadTxtarData(data []byte) error
LoadTxtarData loads a change info history from the txtar file content data. See [LoadTxtar] for a description of the format.