Anime Service
This is the Anime service
Generated with
micro new anime --namespace=hanako --type=srv
Getting Started
Configuration
- FQDN: hanako.srv.anime
- Type: srv
- Alias: anime
Requirements
- Mongodb:
specify mongodb url and database name on .env.
For development purpose, I personally use docker.
I made custom yml to run some of container that needed on this services.
Run this command
make du # For run mongodb
import data to mongodb for the first time
After you run the mongodb container
- Enter to the database from the mongo client cli
$ mongo -u root -p root --authenticationDatabase admin
- Create new database and collection
> use hanako
> db.createCollection("anime")
- Enter to your database
> use hanako
- Create new credential for your database
> db.createUser(
{
user : "root",
pwd : "root",
roles: [ { role: 'root', db: 'admin' } ]
}
)
- Now exit, and to this on the terminal (with your json-array-formatted file)
$ mongoimport --uri "mongodb://root:root@localhost:27017/hanako" --collection anime --file formatted-anime-offline-database.json --jsonArray
Setup
- Create a
.env
file on the folder
- Setup the dev environment there, format
mongo_url=mongodb_url
mongo_dbname=mongo_db_database_name
mongo_username=root
mongo_pwd=root
Dependencies
Micro services depend on service discovery. The default is multicast DNS, a zeroconf system.
In the event you need a resilient multi-host setup we recommend etcd.
# install etcd
brew install etcd
# run etcd
etcd
Usage
A Makefile is included for convenience
Build the binary
make build
Run the service
./anime-srv
Build a docker image
make docker