Giter Site home page Giter Site logo

diem-api's Introduction

DIEM API

CircleCI License: GPL v3 GitHub code size in bytes

目前系统有如下 API:

  1. 一言(Hitokoto)

  2. 网易云音乐(Cloudmusic)

  3. Google 分析(Google Analytics)(这条并没有什么卵用

  4. 博客搜索的 API(仅作流量转发和字段验证)

有关这些 API 的具体信息请移步至 API 的文档(文档包含展示及测试模块,GitHub 无法展示)。

部署

以下依赖都是编译时依赖,并非是运行时的依赖:

  1. Elixir (限流模块使用,二者使用 Unix Domain Socket 通信,可以通过配置文件 [rate-limit] 的 enable 字段禁用掉)

  2. Rust(博客的搜索 API,基于 Tantivy)

如果只想部署 Hitokoto 这一特定 API,则这两个依赖都不需要。

运行参数

支持仅运行某一个 API 服务。比如想只运行 Hitokoto 服务:

./DIEM-API -view=hitokoto

在运行 Hitokoto 服务之前,记得使用如下参数来初始化数据库:

./DIEM-API -migrate

数据库的配置路径以及 Hitokoto 源文件的配置路径在配置文件的 [hitokoto] 字段。其中源文件的每一行格式是包含以下元素的五元组(不同列之间采用制表符分割):

id origin length source hitokoto

释义

一言的主键,整数

可随意填写

一言主体长度,整数

一言的出处

一言主体

举例

1271737837318521026

ohx

16

小王子

我太年轻了,甚至不懂怎么去爱她。

避免侵权,我不会将接口目前使用的一言数据库源文件公开,如果有需要,可以使用 hitokoto.cn 开源的句子,或者使用我之前写的 一言爬虫 来爬取,聪明如你肯定知道如何把 JSON 格式转化成对应的五元组~

普通部署

clone 本仓库并在 diem.toml 修改相关的信息。

go build -o server # (1)
./server -config diem.toml -migrate # (2)
env GIN_MODE=release ./server -config diem.toml # (3)
  1. 编译成二进制

  2. 创建 Hitokoto 的数据库(基于 Bolt)

  3. 生产环境(即设置环境变量 GIN_MODE 为 release)

其中生产环境不会在终端打印日志,而是会把日志都记录在 _log 文件夹内。

容器版部署(推荐)

由于默认采用 Unix Domain Socket 作为通信方式,如果想在 K8s 或者 Docker 或者跨机器部署的话,需要将配置文件里面的 network 的字段值改为 tcp。

致谢

jetbrains

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.