Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Thrift idl as DSL support for go-mir #43

Open
alimy opened this issue Dec 26, 2023 · 1 comment
Open

add Thrift idl as DSL support for go-mir #43

alimy opened this issue Dec 26, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@alimy
Copy link
Owner

alimy commented Dec 26, 2023

Add Thrift idl as DSL support for go-mir

namespace go car

include "../base/common.thrift"
include "../base/car.thrift"

struct AdminCreateCarRequest {
    1:  string plate_num (api.raw = "plate_num", api.vd = "len($) > 0 && len($) < 25>"),
}

struct AdminDeleteCarRequest {
    1:  string id (api.raw = "id", api.vd = "len($) > 0 && len($) < 25>"),
}

struct AdminGetSomeCarsRequest {}

struct AdminGetAllCarsRequest {}

struct GetCarsRequest {}

struct GetCarRequest {
    1:  string id (api.raw = "id", api.vd = "len($) > 0 && len($) < 25>"),
}

service CarService {
    // for back-stage management
    common.NilResponse AdminCreateCar(1: AdminCreateCarRequest req) (api.post = "/admin/car", api.chain = "true"),
    common.NilResponse AdminDeleteCar(1: AdminDeleteCarRequest req) (api.delete = "/admin/car", api.chain = "true"),
    common.NilResponse AdminGetSomeCars(1: AdminGetSomeCarsRequest req) (api.get = "/admin/car/some"),
    common.NilResponse AdminGetAllCars(1: AdminGetAllCarsRequest req) (api.get = "/admin/car/all"),

    // for mini-program
    common.NilResponse GetCars(1: GetCarsRequest req) (api.get = "/cars"),
    common.NilResponse GetCar(1: GetCarRequest req) (api.get = "/car"),
} (api.group = "v1", api.chain = "true")
@alimy alimy self-assigned this Dec 26, 2023
@alimy alimy added the feature label Dec 26, 2023
@alimy alimy added this to the v4.3 milestone Dec 26, 2023
@alimy alimy pinned this issue Dec 26, 2023
@alimy
Copy link
Owner Author

alimy commented Dec 26, 2023

我是看到hertz项目中直接使用了Thrift来描述api服务接口然后生成代码,确定了其可行性,又仔细考量了一下go-mir现有的架构,可以引入该功能特性,逐开始着手落地。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant