27 lines
1.0 KiB
Plaintext
27 lines
1.0 KiB
Plaintext
|
{{with .Annotations.Doc -}}
|
||
|
// {{.}}
|
||
|
{{end -}}
|
||
|
type {{.Node.Name}} struct { Client {{.G.Capnp}}.Client }
|
||
|
|
||
|
{{ template "_typeid" .Node }}
|
||
|
|
||
|
{{range .Methods -}}
|
||
|
func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, params func({{$.G.RemoteNodeName .Params $.Node}}) error, opts ...{{$.G.Capnp}}.CallOption) {{$.G.RemoteNodeName .Results $.Node}}_Promise {
|
||
|
if c.Client == nil {
|
||
|
return {{$.G.RemoteNodeName .Results $.Node}}_Promise{Pipeline: {{$.G.Capnp}}.NewPipeline({{$.G.Capnp}}.ErrorAnswer({{$.G.Capnp}}.ErrNullClient))}
|
||
|
}
|
||
|
call := &{{$.G.Capnp}}.Call{
|
||
|
Ctx: ctx,
|
||
|
Method: {{$.G.Capnp}}.Method{
|
||
|
{{template "_interfaceMethod" .}}
|
||
|
},
|
||
|
Options: {{$.G.Capnp}}.NewCallOptions(opts),
|
||
|
}
|
||
|
if params != nil {
|
||
|
call.ParamsSize = {{$.G.ObjectSize .Params}}
|
||
|
call.ParamsFunc = func(s {{$.G.Capnp}}.Struct) error { return params({{$.G.RemoteNodeName .Params $.Node}}{Struct: s}) }
|
||
|
}
|
||
|
return {{$.G.RemoteNodeName .Results $.Node}}_Promise{Pipeline: {{$.G.Capnp}}.NewPipeline(c.Client.Call(call))}
|
||
|
}
|
||
|
{{end}}
|