pinnacle/api/lua_grpc/pinnacle.lua

46 lines
971 B
Lua
Raw Normal View History

2024-01-12 04:58:35 +01:00
local cqueues = require("cqueues")
local client = require("pinnacle.grpc.client")
---@class PinnacleModule
2024-01-13 00:20:34 +01:00
local pinnacle = {
version = "v0alpha1",
}
2024-01-12 04:58:35 +01:00
---@class Pinnacle
---@field private config_client Client
---@field input Input
local Pinnacle = {}
function Pinnacle:quit()
self.config_client:unary_request({
service = "pinnacle.v0alpha1.PinnacleService",
method = "Quit",
request_type = "pinnacle.v0alpha1.QuitRequest",
data = {},
})
end
---Setup Pinnacle.
---@param config_fn fun(pinnacle: Pinnacle)
function pinnacle.setup(config_fn)
require("pinnacle.grpc.protobuf").build_protos()
2024-01-13 00:20:34 +01:00
2024-01-12 04:58:35 +01:00
local loop = cqueues.new()
2024-01-13 00:20:34 +01:00
2024-01-12 04:58:35 +01:00
local config_client = client.new(loop)
---@type Pinnacle
local self = {
config_client = config_client,
input = require("pinnacle.input").new(config_client),
}
setmetatable(self, { __index = Pinnacle })
config_fn(self)
2024-01-13 00:20:34 +01:00
loop:loop()
2024-01-12 04:58:35 +01:00
end
return pinnacle