这是indexloc提供的服务,不要输入任何密码

providers

package
v0.0.0-...-838b5ba Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AstralProvider

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

func NewAstralProvider

func NewAstralProvider(storage Storage, httpClient HTTPClient, cacheExpire int, randomInt func(int) int) *AstralProvider

func (*AstralProvider) GetCacheKey

func (p *AstralProvider) GetCacheKey() string

func (*AstralProvider) GetName

func (p *AstralProvider) GetName() string

func (*AstralProvider) GetRandomPost

func (p *AstralProvider) GetRandomPost(ctx context.Context) (models.Post, error)

func (*AstralProvider) GetTopPosts

func (p *AstralProvider) GetTopPosts(ctx context.Context) (string, error)

type HTTPClient

type HTTPClient interface {
	Get(ctx context.Context, url string) (*HTTPResponse, error)
	Post(ctx context.Context, url, contentType string, body interface{}) (*HTTPResponse, error)
}

Internal interfaces for providers that may need different signatures

type HTTPClientAdapter

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

func NewHTTPClientAdapter

func NewHTTPClientAdapter(client interfaces.HTTPClient) *HTTPClientAdapter

func (*HTTPClientAdapter) Get

func (*HTTPClientAdapter) Post

func (a *HTTPClientAdapter) Post(ctx context.Context, url, contentType string, body interface{}) (*HTTPResponse, error)

type HTTPResponse

type HTTPResponse struct {
	StatusCode int
	Body       []byte
}

type LessWrongProvider

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

func NewLessWrongProvider

func NewLessWrongProvider(httpClient HTTPClient, randomInt func(int) int) *LessWrongProvider

func (*LessWrongProvider) GetCacheKey

func (p *LessWrongProvider) GetCacheKey() string

func (*LessWrongProvider) GetName

func (p *LessWrongProvider) GetName() string

func (*LessWrongProvider) GetRandomPost

func (p *LessWrongProvider) GetRandomPost(ctx context.Context) (models.Post, error)

func (*LessWrongProvider) GetTopPosts

func (p *LessWrongProvider) GetTopPosts(ctx context.Context) (string, error)

type LessWrongRuProvider

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

func NewLessWrongRuProvider

func NewLessWrongRuProvider(storage Storage, cacheExpire int, randomInt func(int) int) *LessWrongRuProvider

func (*LessWrongRuProvider) GetCacheKey

func (p *LessWrongRuProvider) GetCacheKey() string

func (*LessWrongRuProvider) GetName

func (p *LessWrongRuProvider) GetName() string

func (*LessWrongRuProvider) GetRandomPost

func (p *LessWrongRuProvider) GetRandomPost(ctx context.Context) (models.Post, error)

func (*LessWrongRuProvider) GetTopPosts

func (p *LessWrongRuProvider) GetTopPosts(ctx context.Context) (string, error)

type PostProvider

type PostProvider interface {
	GetRandomPost(ctx context.Context) (models.Post, error)
	GetTopPosts(ctx context.Context) (string, error)
	GetName() string
	GetCacheKey() string
}

type ProviderFactory

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

func NewProviderFactory

func NewProviderFactory(
	storage interfaces.Storage,
	httpClient interfaces.HTTPClient,
	cacheExpire int,
	randomInt func(int) int,
) *ProviderFactory

func (*ProviderFactory) CreateProvider

func (f *ProviderFactory) CreateProvider(source models.Source) PostProvider

func (*ProviderFactory) GetMarkdownConverter

func (f *ProviderFactory) GetMarkdownConverter(source models.Source) *md.Converter

func (*ProviderFactory) ShouldUseURLWithText

func (f *ProviderFactory) ShouldUseURLWithText(source models.Source) bool

type SlateProvider

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

func NewSlateProvider

func NewSlateProvider(storage Storage, cacheExpire int, randomInt func(int) int) *SlateProvider

func (*SlateProvider) GetCacheKey

func (p *SlateProvider) GetCacheKey() string

func (*SlateProvider) GetName

func (p *SlateProvider) GetName() string

func (*SlateProvider) GetRandomPost

func (p *SlateProvider) GetRandomPost(ctx context.Context) (models.Post, error)

func (*SlateProvider) GetTopPosts

func (p *SlateProvider) GetTopPosts(ctx context.Context) (string, error)

type Storage

type Storage interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key, value string, expire int) error
}

type StorageAdapter

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

func NewStorageAdapter

func NewStorageAdapter(storage interfaces.Storage) *StorageAdapter

func (*StorageAdapter) Get

func (a *StorageAdapter) Get(ctx context.Context, key string) (string, error)

func (*StorageAdapter) Set

func (a *StorageAdapter) Set(ctx context.Context, key, value string, expire int) error

Jump to

Keyboard shortcuts

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