publish

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

The publish package provides a publishing service and requires initialization by the caller.

To use the publish package, import the package and its dependencies, such as register, as shown in the following example:

package main

import (
        _ "github.com/wabarc/wayback/publish/register"
        "github.com/wabarc/wayback/publish"
)

func main() {
        // Initialize the publish service with configuration options and a context.
        opts := &config.Options{}
        ctx := context.Background()
        pub := publish.New(ctx, opts)
        go pub.Start()
        defer pub.Stop()

        // Use the publish service to publish data.
        // ...
}

Index

Constants

This section is empty.

Variables

View Source
var Collects = []wayback.Collect{
	{
		Arc: config.SLOT_IA,
		Dst: "https://web.archive.org/web/20211000000001/https://example.com/",
		Src: "https://example.com/",
		Ext: config.SLOT_IA,
	},
	{
		Arc: config.SLOT_IS,
		Dst: "http://archive.today/abcdE",
		Src: "https://example.com/",
		Ext: config.SLOT_IS,
	},
	{
		Arc: config.SLOT_IP,
		Dst: "https://ipfs.io/ipfs/QmTbDmpvQ3cPZG6TA5tnar4ZG6q9JMBYVmX2n3wypMQMtr",
		Src: "https://example.com/",
		Ext: config.SLOT_IP,
	},
	{
		Arc: config.SLOT_PH,
		Dst: "http://telegra.ph/title-01-01",
		Src: "https://example.com/",
		Ext: config.SLOT_PH,
	},
}

Functions

func Artifact added in v0.19.0

func Artifact(ctx context.Context, rdx reduxer.Reduxer, cols []wayback.Collect) (art reduxer.Artifact, err error)

Artifact returns an artifact from the reduxer that corresponds to the first collect in the provided slice of collects. If the artifact is not found in the reduxer, an error is returned.

func Register added in v0.19.0

func Register(flag Flag, action SetupFunc)

Register registers a publish client's setup function and allows it to be called.

Types

type Flag added in v0.16.0

type Flag uint8

Flag represents a type of uint8

const (
	FlagWeb      Flag = iota // FlagWeb publish from httpd service
	FlagTelegram             // FlagTelegram publish from telegram service
	FlagTwitter              // FlagTwitter publish from twitter srvice
	FlagMastodon             // FlagMastodon publish from mastodon service
	FlagDiscord              // FlagDiscord publish from discord service
	FlagMatrix               // FlagMatrix publish from matrix service
	FlagSlack                // FlagSlack publish from slack service
	FlagNostr                // FlagSlack publish from nostr
	FlagIRC                  // FlagIRC publish from relaychat service
	FlagNotion               // FlagNotion is a flag for notion publish service
	FlagGitHub               // FlagGitHub is a flag for github publish service
	FlagMeili                // FlagMeili is a flag for meilisearch publish service
)

func (Flag) String added in v0.16.0

func (f Flag) String() string

String returns the flag as a string.

type Module added in v0.19.0

type Module struct {
	Publisher

	Opts *config.Options
	Flag Flag
}

Module is a struct embeds the Publisher interface and holds a pointer to config.Options.

type Publish added in v0.19.0

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

Publish handles options for publish service.

func New added in v0.19.0

func New(ctx context.Context, opts *config.Options) *Publish

New creates a Publish struct with the given context and configuration options. It initializes a new pooling with the context and options, and parses all available modules.

Returns a new Publish with the provided options and pooling.

func (*Publish) Spread added in v0.19.0

func (p *Publish) Spread(ctx context.Context, rdx reduxer.Reduxer, cols []wayback.Collect, from Flag, args ...string)

Spread accepts calls from services that with collections and various parameters. It prepare all available publishers and put them into pooling.

func (*Publish) Start added in v0.19.0

func (p *Publish) Start()

Start starts the publish service on the underlying pooling service. It is blocking and should be handled in a separate goroutine.

func (*Publish) Stop added in v0.19.0

func (p *Publish) Stop()

Stop stop the Publish pooling. It waits until the pool status is idle and then calls Stop on the pool.

Stop uses a sync.Once to ensure that Stop is only called once.

type Publisher added in v0.14.0

type Publisher interface {
	Publish(context.Context, reduxer.Reduxer, []wayback.Collect, ...string) error
}

Publisher is the interface that wraps the basic Publish method.

Publish publish message to serveral media platforms, e.g. Telegram channel, GitHub Issues, etc. The cols must either be a []wayback.Collect, args use for specific service.

type SetupFunc added in v0.19.0

type SetupFunc func(*config.Options) *Module

SetupFunc is a function type that takes a pointer to a config.Options struct and returns a pointer to a Module struct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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