azan

package module
v0.0.0-...-32ae133 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 2 Imported by: 0

README

Azan-Schedule

This application to generate Azan Schedule or Sholat Schedule based on position(latitude, longitude, and timezone). This can be used at the smartphone if golang already support for android/ios.

How To Use

Get Dependency
  1. Run govendor sync
Build CLI

If you want to generate files that set the azan schedule, build the cli

  1. Build the application using make cli
  2. Run ./azan_cli generate --latitude=-6.18 --longitude=106.83 --timezone=+7 --city=jakarta for generating schedule in json format
  3. Run ./azan_cli play to play azan manually
  4. Run ./azan_cli start to play azan automatically as scheduled
Build API Server

If you want to setup server for azan schedule, you can build the api server

Dependency
  1. MYSQL
  2. MEMCACHED
Build
  1. Build the api server using make api
  2. Change env.sample to .env and edit the value as you need
  3. Run ./azan_api
  4. Apps will listen on port 1234

How To Develop

Calculation

You may develop your own calculation implementation, see provider.go for the contract about the calculation function and place it under calculation package

Database

You may develop your own database implementation (if you want to use other db other than mysql), see provider.go for the contract about database function and place it under database package

Cache

You may develop your own cache implementation (if you want to use other cache engine other than memcache), see provider.go for the contract about cache function and place it under cache package

The MIT License (MIT)

Copyright (c) 2015 Dr. T. Djamaluddin, Wastono ST

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Azan

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

azan

func New

func New(database DbProvider, cache CacheProvider, calculation CalcProvider) *Azan

func (*Azan) Generate

func (a *Azan) Generate(latitude, longitude, timezone float64, city string) error

func (*Azan) GetAll

func (a *Azan) GetAll() ([]CalcResult, error)

func (*Azan) GetByCity

func (a *Azan) GetByCity(city string) (CalcResult, error)

func (*Azan) GetByCityDate

func (a *Azan) GetByCityDate(city string, date time.Time) (CalcResult, error)

func (*Azan) GetByCityMonth

func (a *Azan) GetByCityMonth(city string, month int) (CalcResult, error)

func (*Azan) GetCache

func (a *Azan) GetCache(key string) ([]byte, error)

func (*Azan) GetCities

func (a *Azan) GetCities() ([]CalcResult, error)

func (*Azan) SetCache

func (a *Azan) SetCache(key string, data []byte) error

type AzanSchedule

type AzanSchedule struct {
	Date    string `json:"date"`
	Fajr    string `json:"fajr"`
	Sunrise string `json:"sunrise"`
	Zuhr    string `json:"zuhr"`
	Asr     string `json:"asr"`
	Maghrib string `json:"maghrib"`
	Isya    string `json:"isya"`
}

type CacheProvider

type CacheProvider interface {
	Set(string, []byte) error
	Get(string) ([]byte, error)
}

cache contract

type CalcProvider

type CalcProvider interface {
	// latitude, longitude, timezone, city
	Calculate(float64, float64, float64, string) CalcResult
}

calculation contract

type CalcResult

type CalcResult struct {
	City      string         `json:"city"`
	Latitude  float64        `json:"lat"`
	Longitude float64        `json:"long"`
	Timezone  float64        `json:"timezone"`
	Schedule  []AzanSchedule `json:"schedule"`
}

type DbProvider

type DbProvider interface {
	Set(CalcResult) error
	Validate(float64, float64, string) (bool, error)
	GetAll() ([]CalcResult, error)
	GetByCity(string) (CalcResult, error)
	GetByCityDate(string, time.Time) (CalcResult, error)
	GetByCityMonth(string, int) (CalcResult, error)
	GetCities() ([]CalcResult, error)
}

database contract

Directories

Path Synopsis
app
api
cli
mp3

Jump to

Keyboard shortcuts

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