Skip to content

Commit

Permalink
Performs minor documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nkcr committed Jul 6, 2022
1 parent 08b6617 commit fd63585
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
[![Go Tests](https://github.com/nkcr/OSIA/actions/workflows/go.yml/badge.svg)](https://github.com/nkcr/OSIA/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/nkcr/OSIA/badge.svg?branch=main)](https://coveralls.io/github/nkcr/OSIA?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/nkcr/OSIA)](https://goreportcard.com/report/github.com/nkcr/OSIA)
[![Go Reference](https://pkg.go.dev/badge/github.com/nkcr/OSIA.svg)](https://pkg.go.dev/github.com/nkcr/OSIA)

OSIA stores your public instagram feed on a DB and offers a simple REST API to
later use your it wherever you want. This is especially convenient to display
your instagram posts on a website.
OSIA is a service that maintains a copy of your Instagram feed and exposes it
with a simple REST API. It is especially convenient for displaying instagram
posts on a website.

The application is composed of an aggregator, which periodically checks new
posts and saves them on a local database, and an HTTP server, which serves posts
Expand Down
10 changes: 7 additions & 3 deletions aggregator/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
// Aggregator defines the primitives required for an Aggregator. An aggregator's
// job is to periodically fetch new entries and store them on a database.
type Aggregator interface {
// Start should start a goroutine that periodically fetches content on
// Instagram and update the local database accordingly.
// Start should start a goroutine that periodically fetches content from
// Instagram and updates the local database accordingly.
Start(interval time.Duration) error

// Stop should stop the periodical update and free resources.
Expand Down Expand Up @@ -49,7 +49,7 @@ func NewInstagramAggregator(db *buntdb.DB, api instagram.InstagramAPI,
}
}

// Aggregator implements an aggregator that fetches Instagram posts.
// InstagramAggregator implements an aggregator that fetches Instagram posts.
//
// - implements aggregator.Aggregator
type InstagramAggregator struct {
Expand Down Expand Up @@ -88,6 +88,8 @@ func (a *InstagramAggregator) Start(interval time.Duration) error {
}
}

// updateMedias gets the latest medias from Instagram and saves those that are
// not yet in the db.
func (a *InstagramAggregator) updateMedias() error {
a.logger.Info().Msg("refreshing token")
err := a.api.RefreshToken()
Expand Down Expand Up @@ -160,6 +162,8 @@ func (a *InstagramAggregator) updateMedias() error {
return nil
}

// saveImage downloads an Instagram post's image and saves it locally to be
// served.
func saveImage(url, path string, client HTTPClient) error {
resp, err := client.Get(url)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions instagram/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func NewHTTPAPI(token string, client HTTPClient) InstagramAPI {

// HTTPAPI implements the Instagram API over HTTP
//
// - implements InstagramAPI
// - implements instagram.InstagramAPI
type HTTPAPI struct {
base string
token string
client HTTPClient
}

// GetMedias implements InstagramAPI
// GetMedias implements instagram.InstagramAPI
func (h HTTPAPI) GetMedias() (types.Medias, error) {
vals := url.Values{
"access_token": []string{h.token},
Expand Down Expand Up @@ -71,7 +71,7 @@ func (h HTTPAPI) GetMedias() (types.Medias, error) {
return medias, nil
}

// GetMedia implements InstagramAPI
// GetMedia implements instagram.InstagramAPI
func (h HTTPAPI) GetMedia(id string) (types.Media, error) {
vals := url.Values{
"access_token": []string{h.token},
Expand Down Expand Up @@ -102,7 +102,7 @@ func (h HTTPAPI) GetMedia(id string) (types.Media, error) {
return media, nil
}

// RefreshToken implements InstagramAPI
// RefreshToken implements instagram.InstagramAPI
func (h *HTTPAPI) RefreshToken() error {
vals := url.Values{
"access_token": []string{h.token},
Expand Down

0 comments on commit fd63585

Please sign in to comment.