Coder Social home page Coder Social logo

pinglist-api's Introduction

Codeship Status for RichardKnop/pinglist-api

Donate Bitcoin

pinglist-api

API / website uptime & performance monitoring platform.

See also:

Index

Dependencies

According to Go 1.5 Vendor experiment, all dependencies are stored in the vendor directory. This approach is called vendoring and is the best practice for Go projects to lock versions of dependencies in order to achieve reproducible builds.

To update dependencies during development:

make update-deps

To install dependencies:

make install-deps

Setup

If you are developing on OSX, install etcd, Postgres:

brew install etcd
brew install postgres

You might want to create a Postgres database:

createuser --createdb pinglist
createdb -U pinglist pinglist

Load a development configuration into etcd:

curl -L http://localhost:2379/v2/keys/config/pinglist.json -XPUT -d value='{
    "Database": {
        "Type": "postgres",
        "Host": "localhost",
        "Port": 5432,
        "User": "pinglist",
        "Password": "",
        "DatabaseName": "pinglist",
        "MaxIdleConns": 5,
        "MaxOpenConns": 5
    },
    "Oauth": {
        "AccessTokenLifetime": 3600,
        "RefreshTokenLifetime": 1209600,
        "AuthCodeLifetime": 3600
    },
    "AWS": {
        "Region": "us-west-2",
        "AssetsBucket": "prod.pinglist.assets",
        "APNSPlatformApplicationARN": "apns_platform_application_arn",
        "GCMPlatformApplicationARN": "gcm_platform_application_arn"
    },
    "Facebook": {
        "AppID": "facebook_app_id",
        "AppSecret": "facebook_app_secret"
    },
    "Sendgrid": {
        "APIKey": "sendgrid_api_key"
    },
    "Stripe": {
        "SecretKey": "stripe_secret_key",
        "PublishableKey": "stripe_publishable_key"
    },
    "Slack": {
        "Username": "webhookbot",
        "Emoji": ""
    },
    "Web": {
        "AppScheme": "http",
        "AppHost": "localhost:8000"
    },
    "Pinglist": {
        "PasswordResetLifetime": 604800,
        "ContactEmail": "[email protected]"
    },
    "IsDevelopment": true
}'

Run migrations:

go run main.go migrate

And finally, run the app:

go run main.go runserver

When deploying, you can set ETCD_HOST and ETCD_PORT environment variables.

Test Data

You might want to insert some test data if you are testing locally using curl examples from this README:

go run main.go loaddata \
	oauth/fixtures/scopes.yml \
	oauth/fixtures/test_clients.yml \
	oauth/fixtures/test_users.yml \
	accounts/fixtures/roles.yml \
	accounts/fixtures/test_accounts.yml \
	accounts/fixtures/test_users.yml \
	subscriptions/fixtures/plans.yml \
	alarms/fixtures/regions.yml \
	alarms/fixtures/alarm_states.yml \
	alarms/fixtures/incident_types.yml

Testing

I have used a mix of unit and functional tests so you need to have sqlite installed in order for the tests to run successfully as the suite creates an in-memory database.

Set the STRIPE_KEY environment variable to match your test private key, then run make test:

STRIPE_KEY=YOUR_API_KEY make test

Docker

Build a Docker image and run the app in a container:

docker build -t pinglist-api .
docker run -e ETCD_HOST=localhost -e ETCD_PORT=2379 -p 6060:8080 pinglist-api

You can load fixtures with docker exec command:

docker exec <container_id> /go/bin/pinglist-api loaddata \
	oauth/fixtures/scopes.yml \
	accounts/fixtures/roles.yml \
	subscriptions/fixtures/plans.yml \
	alarms/fixtures/regions.yml \
	alarms/fixtures/alarm_states.yml \
	alarms/fixtures/incident_types.yml \
	oauth/fixtures/test_clients.yml \
	accounts/fixtures/test_accounts.yml

You can also execute interactive commands by passing -i flag:

docker exec -i <container_id> /go/bin/pinglist-api createaccount
docker exec -i <container_id> /go/bin/pinglist-api createsuperuser

Releasing

First, cut a release using cut-release.sh script. If you make a mistake, you can re-run the script as it will force push tags.

./cut-release.sh v0.0.0 --no-dry-run

Second, build a release using build-release.sh script. It will build a Docker image, tag it and push it to S3 bucket bucket. It might take a while depending on your connection speed as gzipped image is about 270MB.

./build-release.sh v0.0.0 --no-dry-run

pinglist-api's People

Contributors

richardknop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

mariusrosoga

pinglist-api's Issues

Store Metrics Averages

Currently request times are stored for each alarm (roughly each 60 seconds). Since this is a lot of data, the metrics table is vertically partitioned and sub tables are being rotated out after 30 days.

Store averages in a separate table for later use.

This will also be needed by the app to display:

  • daily request times
  • weekly request times
  • monthly request times

Team Invitations

When adding / editing teams, if a user not yet in our database is used in members slice, send invitation email and add the invited user to the team.

Maintenance Script

Write a maintenance script which will:

  • check for users who have more activate alarms then their subscription level allows
  • deactivate alarms that are above their threshold
  • do not deactivate immediately, first record users to a table and wait X days before turning off their excessive alarms
  • possibly send an email to them before deactivating

Do Not Delete Card On Active Subscription

When a user attempts to delete a card, check if there is an active subscription using the card.

If there is, deny deleting of a card. Subscription must be cancelled first or changed to a different card before card can be deleted.

This will require making subscription.card_id relation optional (so it can be NULL).

Different Email Per Incident

Different incidents should trigger custom email alerts. Right now these incident types are defined:

  • slow_response
  • timeout
  • bad_code
  • other

Alert emails should be tailored for each incident type differently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.