WIP node api

This commit is contained in:
mcrakhman 2022-12-03 13:09:15 +01:00 committed by Mikhail Iudin
parent 75706111ee
commit 5098daf152
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
11 changed files with 248 additions and 130 deletions

View File

@ -867,65 +867,66 @@ func (m *LoadSpaceResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_LoadSpaceResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*CreateSpaceRequest)(nil), "api.CreateSpaceRequest")
proto.RegisterType((*CreateSpaceResponse)(nil), "api.CreateSpaceResponse")
proto.RegisterType((*DeriveSpaceRequest)(nil), "api.DeriveSpaceRequest")
proto.RegisterType((*DeriveSpaceResponse)(nil), "api.DeriveSpaceResponse")
proto.RegisterType((*CreateDocumentRequest)(nil), "api.CreateDocumentRequest")
proto.RegisterType((*CreateDocumentResponse)(nil), "api.CreateDocumentResponse")
proto.RegisterType((*DeleteDocumentRequest)(nil), "api.DeleteDocumentRequest")
proto.RegisterType((*DeleteDocumentResponse)(nil), "api.DeleteDocumentResponse")
proto.RegisterType((*AddTextRequest)(nil), "api.AddTextRequest")
proto.RegisterType((*AddTextResponse)(nil), "api.AddTextResponse")
proto.RegisterType((*DumpTreeRequest)(nil), "api.DumpTreeRequest")
proto.RegisterType((*DumpTreeResponse)(nil), "api.DumpTreeResponse")
proto.RegisterType((*AllTreesRequest)(nil), "api.AllTreesRequest")
proto.RegisterType((*Tree)(nil), "api.Tree")
proto.RegisterType((*AllTreesResponse)(nil), "api.AllTreesResponse")
proto.RegisterType((*AllSpacesRequest)(nil), "api.AllSpacesRequest")
proto.RegisterType((*AllSpacesResponse)(nil), "api.AllSpacesResponse")
proto.RegisterType((*LoadSpaceRequest)(nil), "api.LoadSpaceRequest")
proto.RegisterType((*LoadSpaceResponse)(nil), "api.LoadSpaceResponse")
proto.RegisterType((*CreateSpaceRequest)(nil), "clientapi.CreateSpaceRequest")
proto.RegisterType((*CreateSpaceResponse)(nil), "clientapi.CreateSpaceResponse")
proto.RegisterType((*DeriveSpaceRequest)(nil), "clientapi.DeriveSpaceRequest")
proto.RegisterType((*DeriveSpaceResponse)(nil), "clientapi.DeriveSpaceResponse")
proto.RegisterType((*CreateDocumentRequest)(nil), "clientapi.CreateDocumentRequest")
proto.RegisterType((*CreateDocumentResponse)(nil), "clientapi.CreateDocumentResponse")
proto.RegisterType((*DeleteDocumentRequest)(nil), "clientapi.DeleteDocumentRequest")
proto.RegisterType((*DeleteDocumentResponse)(nil), "clientapi.DeleteDocumentResponse")
proto.RegisterType((*AddTextRequest)(nil), "clientapi.AddTextRequest")
proto.RegisterType((*AddTextResponse)(nil), "clientapi.AddTextResponse")
proto.RegisterType((*DumpTreeRequest)(nil), "clientapi.DumpTreeRequest")
proto.RegisterType((*DumpTreeResponse)(nil), "clientapi.DumpTreeResponse")
proto.RegisterType((*AllTreesRequest)(nil), "clientapi.AllTreesRequest")
proto.RegisterType((*Tree)(nil), "clientapi.Tree")
proto.RegisterType((*AllTreesResponse)(nil), "clientapi.AllTreesResponse")
proto.RegisterType((*AllSpacesRequest)(nil), "clientapi.AllSpacesRequest")
proto.RegisterType((*AllSpacesResponse)(nil), "clientapi.AllSpacesResponse")
proto.RegisterType((*LoadSpaceRequest)(nil), "clientapi.LoadSpaceRequest")
proto.RegisterType((*LoadSpaceResponse)(nil), "clientapi.LoadSpaceResponse")
}
func init() { proto.RegisterFile("api/apiproto/protos/api.proto", fileDescriptor_fc31080c27db9707) }
var fileDescriptor_fc31080c27db9707 = []byte{
// 544 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x6f, 0xd3, 0x40,
0x10, 0x8d, 0x93, 0xf4, 0xc3, 0x13, 0x94, 0xa4, 0x93, 0x0f, 0x2c, 0x23, 0x4c, 0xb4, 0x12, 0x55,
0x24, 0xaa, 0x46, 0xb4, 0x48, 0x48, 0x9c, 0x1a, 0x9a, 0x4b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4d, 0x9d, 0xa8, 0x67, 0x36, 0x85, 0x56, 0xaa, 0x4f, 0xf7, 0x2d, 0xca, 0x18, 0x25,
0x99, 0x3e, 0xec, 0x7f, 0x15, 0x2e, 0x4f, 0x47, 0x50, 0xc5, 0xde, 0x41, 0x6b, 0xb2, 0x5e, 0xc8,
0xab, 0x95, 0x10, 0x0f, 0xff, 0x45, 0x8e, 0xa1, 0x9d, 0x89, 0xd1, 0x62, 0x08, 0x75, 0xbe, 0x5e,
0x48, 0x92, 0x52, 0xcf, 0xec, 0x05, 0xb4, 0xc6, 0xf3, 0x79, 0xd4, 0x16, 0xfc, 0xff, 0x1d, 0x9f,
0x40, 0x3d, 0xea, 0xd4, 0xdf, 0x28, 0x76, 0x61, 0x2f, 0xba, 0x43, 0x60, 0x55, 0x07, 0xb5, 0xa1,
0x39, 0x8b, 0x0b, 0x76, 0x0e, 0xed, 0x4c, 0x9a, 0x56, 0x78, 0x06, 0x7b, 0x61, 0x04, 0x58, 0xc6,
0xa0, 0x36, 0x6c, 0x9c, 0x99, 0xa7, 0x91, 0xe5, 0xd5, 0x92, 0x31, 0xce, 0x50, 0x91, 0x94, 0x3b,
0x93, 0x85, 0xd8, 0x08, 0x8e, 0x72, 0x18, 0x29, 0xd9, 0x70, 0x48, 0x6b, 0xc5, 0x62, 0xe6, 0x2c,
0xad, 0xd9, 0x09, 0xb4, 0xdf, 0xfb, 0x2e, 0xcf, 0x3b, 0xff, 0x1f, 0xb7, 0xea, 0xc0, 0x51, 0xae,
0x3b, 0x96, 0x3f, 0xfb, 0x59, 0x07, 0xf3, 0x72, 0xee, 0x89, 0x65, 0x38, 0x96, 0x1e, 0x5e, 0x40,
0x23, 0x97, 0x39, 0x7c, 0xac, 0xd6, 0x2e, 0x67, 0xd3, 0xb6, 0xca, 0x07, 0xb4, 0xee, 0x05, 0x34,
0x72, 0xc1, 0x23, 0x85, 0x72, 0x40, 0x49, 0x61, 0x57, 0x46, 0xa7, 0xd0, 0x2c, 0x06, 0x0c, 0xed,
0xdc, 0x34, 0x2d, 0x4b, 0xf6, 0x93, 0x9d, 0x67, 0x99, 0x54, 0x31, 0x2e, 0x24, 0xb5, 0x33, 0x96,
0x24, 0xb5, 0x3b, 0x5f, 0xf8, 0x0a, 0x0e, 0xc8, 0xff, 0xd8, 0x51, 0x7d, 0xc5, 0xb4, 0xd9, 0xdd,
0x22, 0x48, 0xac, 0xd7, 0x70, 0x98, 0xb8, 0x13, 0xe3, 0x0e, 0xcd, 0xf9, 0x76, 0x4f, 0x43, 0x33,
0x62, 0xe2, 0x29, 0x22, 0x6a, 0xee, 0x25, 0x62, 0xc9, 0x78, 0x6f, 0xc0, 0x4c, 0x3d, 0x84, 0x69,
0x4f, 0xc1, 0x67, 0x76, 0x5f, 0x87, 0x33, 0x6e, 0x6a, 0x10, 0xe2, 0xea, 0xf6, 0x22, 0x6e, 0xc9,
0x47, 0x6f, 0x8f, 0x7f, 0x6d, 0x1c, 0xe3, 0x76, 0xe3, 0x18, 0x7f, 0x36, 0x8e, 0xf1, 0x63, 0xeb,
0x54, 0x6e, 0xb7, 0x4e, 0xe5, 0xf7, 0xd6, 0xa9, 0x7c, 0x7a, 0x94, 0xff, 0x07, 0xf8, 0xb2, 0xaf,
0xbe, 0xce, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x7a, 0xb5, 0x35, 0xcb, 0x18, 0x06, 0x00, 0x00,
// 553 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcb, 0x6e, 0xd3, 0x40,
0x14, 0x86, 0xe3, 0x5c, 0xda, 0xfa, 0x04, 0x25, 0xe9, 0x69, 0x1b, 0x19, 0x43, 0xad, 0x30, 0x52,
0xab, 0x48, 0x54, 0x89, 0x28, 0x2b, 0x76, 0x84, 0x44, 0x48, 0x11, 0xd9, 0x10, 0xca, 0x86, 0x05,
0x92, 0xc9, 0x8c, 0x84, 0xa5, 0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x74, 0xfb, 0x61, 0x27, 0x37, 0x3f, 0xe3, 0x37, 0xfb, 0xd9, 0x3d, 0x15, 0x29, 0x56,
0x37, 0x96, 0x86, 0x2d, 0xb4, 0xb1, 0x86, 0x2d, 0x76, 0x25, 0xbe, 0x86, 0x43, 0xe9, 0x1a, 0x7c,
0xac, 0x54, 0xeb, 0x4e, 0xb5, 0xed, 0xa2, 0x94, 0x24, 0x0c, 0xe1, 0x28, 0xd6, 0x37, 0xaa, 0x75,
0x19, 0x07, 0xd9, 0x4f, 0x0a, 0x73, 0x29, 0x24, 0x56, 0xa8, 0x06, 0xc9, 0x38, 0x42, 0x83, 0xe4,
0x24, 0xfd, 0x16, 0xcc, 0x44, 0x97, 0x98, 0xa9, 0xd4, 0x14, 0x6c, 0x3f, 0x2d, 0x4e, 0xa6, 0x9c,
0x44, 0x80, 0x1a, 0x27, 0x2b, 0x62, 0x8d, 0x93, 0xd3, 0xec, 0x9b, 0xcb, 0x5f, 0x5b, 0xc7, 0xb8,
0xdb, 0x3a, 0xc6, 0x9f, 0xad, 0x63, 0xfc, 0xd8, 0x39, 0xa5, 0xbb, 0x9d, 0x53, 0xfa, 0xbd, 0x73,
0x4a, 0x9f, 0x1e, 0xa9, 0xff, 0x3c, 0x5f, 0x0e, 0xc4, 0xd7, 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff,
0xff, 0x5d, 0x2e, 0xfd, 0x34, 0x90, 0x06, 0x00, 0x00,
}
func (m *CreateSpaceRequest) Marshal() (dAtA []byte, err error) {

View File

@ -63,7 +63,7 @@ func (c *drpcClientApiClient) DRPCConn() drpc.Conn { return c.cc }
func (c *drpcClientApiClient) CreateSpace(ctx context.Context, in *CreateSpaceRequest) (*CreateSpaceResponse, error) {
out := new(CreateSpaceResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -72,7 +72,7 @@ func (c *drpcClientApiClient) CreateSpace(ctx context.Context, in *CreateSpaceRe
func (c *drpcClientApiClient) DeriveSpace(ctx context.Context, in *DeriveSpaceRequest) (*DeriveSpaceResponse, error) {
out := new(DeriveSpaceResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -81,7 +81,7 @@ func (c *drpcClientApiClient) DeriveSpace(ctx context.Context, in *DeriveSpaceRe
func (c *drpcClientApiClient) CreateDocument(ctx context.Context, in *CreateDocumentRequest) (*CreateDocumentResponse, error) {
out := new(CreateDocumentResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -90,7 +90,7 @@ func (c *drpcClientApiClient) CreateDocument(ctx context.Context, in *CreateDocu
func (c *drpcClientApiClient) DeleteDocument(ctx context.Context, in *DeleteDocumentRequest) (*DeleteDocumentResponse, error) {
out := new(DeleteDocumentResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -99,7 +99,7 @@ func (c *drpcClientApiClient) DeleteDocument(ctx context.Context, in *DeleteDocu
func (c *drpcClientApiClient) AddText(ctx context.Context, in *AddTextRequest) (*AddTextResponse, error) {
out := new(AddTextResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -108,7 +108,7 @@ func (c *drpcClientApiClient) AddText(ctx context.Context, in *AddTextRequest) (
func (c *drpcClientApiClient) DumpTree(ctx context.Context, in *DumpTreeRequest) (*DumpTreeResponse, error) {
out := new(DumpTreeResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -117,7 +117,7 @@ func (c *drpcClientApiClient) DumpTree(ctx context.Context, in *DumpTreeRequest)
func (c *drpcClientApiClient) AllTrees(ctx context.Context, in *AllTreesRequest) (*AllTreesResponse, error) {
out := new(AllTreesResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -126,7 +126,7 @@ func (c *drpcClientApiClient) AllTrees(ctx context.Context, in *AllTreesRequest)
func (c *drpcClientApiClient) AllSpaces(ctx context.Context, in *AllSpacesRequest) (*AllSpacesResponse, error) {
out := new(AllSpacesResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -135,7 +135,7 @@ func (c *drpcClientApiClient) AllSpaces(ctx context.Context, in *AllSpacesReques
func (c *drpcClientApiClient) LoadSpace(ctx context.Context, in *LoadSpaceRequest) (*LoadSpaceResponse, error) {
out := new(LoadSpaceResponse)
err := c.cc.Invoke(ctx, "/api.ClientApi/LoadSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/clientapi.ClientApi/LoadSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -199,7 +199,7 @@ func (DRPCClientApiDescription) NumMethods() int { return 9 }
func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
switch n {
case 0:
return "/api.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
CreateSpace(
@ -208,7 +208,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.CreateSpace, true
case 1:
return "/api.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
DeriveSpace(
@ -217,7 +217,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.DeriveSpace, true
case 2:
return "/api.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
CreateDocument(
@ -226,7 +226,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.CreateDocument, true
case 3:
return "/api.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
DeleteDocument(
@ -235,7 +235,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.DeleteDocument, true
case 4:
return "/api.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
AddText(
@ -244,7 +244,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.AddText, true
case 5:
return "/api.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
DumpTree(
@ -253,7 +253,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.DumpTree, true
case 6:
return "/api.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
AllTrees(
@ -262,7 +262,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.AllTrees, true
case 7:
return "/api.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
AllSpaces(
@ -271,7 +271,7 @@ func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Recei
)
}, DRPCClientApiServer.AllSpaces, true
case 8:
return "/api.ClientApi/LoadSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/clientapi.ClientApi/LoadSpace", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCClientApiServer).
LoadSpace(

View File

@ -1,5 +1,5 @@
syntax = "proto3";
package api;
package clientapi;
option go_package = "api/apiproto";

View File

@ -339,40 +339,41 @@ func (m *AllSpacesResponse) GetSpaceIds() []string {
}
func init() {
proto.RegisterType((*DumpTreeRequest)(nil), "api.DumpTreeRequest")
proto.RegisterType((*DumpTreeResponse)(nil), "api.DumpTreeResponse")
proto.RegisterType((*AllTreesRequest)(nil), "api.AllTreesRequest")
proto.RegisterType((*Tree)(nil), "api.Tree")
proto.RegisterType((*AllTreesResponse)(nil), "api.AllTreesResponse")
proto.RegisterType((*AllSpacesRequest)(nil), "api.AllSpacesRequest")
proto.RegisterType((*AllSpacesResponse)(nil), "api.AllSpacesResponse")
proto.RegisterType((*DumpTreeRequest)(nil), "nodeapi.DumpTreeRequest")
proto.RegisterType((*DumpTreeResponse)(nil), "nodeapi.DumpTreeResponse")
proto.RegisterType((*AllTreesRequest)(nil), "nodeapi.AllTreesRequest")
proto.RegisterType((*Tree)(nil), "nodeapi.Tree")
proto.RegisterType((*AllTreesResponse)(nil), "nodeapi.AllTreesResponse")
proto.RegisterType((*AllSpacesRequest)(nil), "nodeapi.AllSpacesRequest")
proto.RegisterType((*AllSpacesResponse)(nil), "nodeapi.AllSpacesResponse")
}
func init() { proto.RegisterFile("api/apiproto/protos/api.proto", fileDescriptor_fc31080c27db9707) }
var fileDescriptor_fc31080c27db9707 = []byte{
// 336 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x4e, 0xea, 0x40,
0x14, 0x65, 0x0a, 0x3c, 0xe8, 0x7d, 0x46, 0x70, 0x82, 0xa6, 0x21, 0x71, 0x24, 0xb3, 0x20, 0x24,
0x1a, 0x48, 0x60, 0x41, 0xe2, 0x0e, 0xe3, 0x86, 0x98, 0xb8, 0xa8, 0xae, 0xdc, 0x55, 0x66, 0x12,
0x27, 0x01, 0x3a, 0x32, 0xed, 0x7f, 0xf8, 0x37, 0xfe, 0x82, 0x4b, 0x96, 0x2e, 0x4d, 0xfb, 0x23,
0x66, 0xa6, 0xd3, 0x52, 0xeb, 0xc2, 0x4d, 0x3b, 0xf7, 0xcc, 0xbd, 0xe7, 0x9c, 0x7b, 0x32, 0x70,
0x1e, 0x48, 0x31, 0x09, 0xa4, 0x90, 0xbb, 0x30, 0x0a, 0x27, 0xe6, 0xab, 0x74, 0x3d, 0x36, 0x47,
0x5c, 0x0f, 0xa4, 0xa0, 0x77, 0xd0, 0xb9, 0x8d, 0x37, 0xf2, 0x71, 0xc7, 0xb9, 0xcf, 0x5f, 0x63,
0xae, 0x22, 0xec, 0x41, 0x4b, 0xc9, 0x60, 0xc5, 0x97, 0xcc, 0x43, 0x03, 0x34, 0x72, 0xfd, 0xbc,
0xc4, 0x04, 0x80, 0x85, 0xab, 0x78, 0xc3, 0xb7, 0xd1, 0x92, 0x79, 0x8e, 0xb9, 0x2c, 0x21, 0x74,
0x08, 0xdd, 0x03, 0x99, 0x92, 0xe1, 0x56, 0x71, 0x8c, 0xa1, 0xc1, 0xe2, 0x8d, 0xb4, 0x54, 0xe6,
0x4c, 0x2f, 0xa1, 0xb3, 0x58, 0xaf, 0x75, 0x9b, 0xfa, 0x53, 0x94, 0x5e, 0x41, 0x43, 0x77, 0xe2,
0x63, 0x70, 0x44, 0x7e, 0xe9, 0x08, 0x86, 0x7b, 0xd0, 0x7c, 0xe1, 0x01, 0x53, 0x9e, 0x33, 0xa8,
0x8f, 0x5c, 0x3f, 0x2b, 0xe8, 0x0c, 0xba, 0x07, 0x6a, 0x6b, 0xe1, 0x02, 0x9a, 0x91, 0x06, 0x3c,
0x34, 0xa8, 0x8f, 0xfe, 0x4f, 0xdd, 0xb1, 0xce, 0xc0, 0x98, 0xcc, 0x70, 0x8a, 0xcd, 0xd0, 0x83,
0x16, 0xcc, 0x0d, 0xd1, 0x09, 0x9c, 0x94, 0x30, 0xcb, 0xd4, 0x87, 0xb6, 0xb5, 0x95, 0x91, 0xb9,
0x7e, 0x51, 0x4f, 0xdf, 0x11, 0xb4, 0xee, 0x43, 0xc6, 0x17, 0x52, 0xe0, 0x39, 0xb4, 0xf3, 0x20,
0x70, 0xcf, 0xc8, 0x55, 0x42, 0xee, 0x9f, 0x56, 0x50, 0x2b, 0x30, 0x87, 0x76, 0x6e, 0xdf, 0x0e,
0x56, 0x82, 0xb2, 0x83, 0xbf, 0x76, 0xbc, 0x06, 0xb7, 0xb0, 0x8b, 0x8b, 0x9e, 0x1f, 0x2b, 0xf5,
0xcf, 0xaa, 0x70, 0x36, 0x7b, 0x33, 0xfc, 0x48, 0x08, 0xda, 0x27, 0x04, 0x7d, 0x25, 0x04, 0xbd,
0xa5, 0xa4, 0xb6, 0x4f, 0x49, 0xed, 0x33, 0x25, 0xb5, 0xa7, 0xa3, 0xf2, 0x0b, 0x7a, 0xfe, 0x67,
0x7e, 0xb3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0xcf, 0x0b, 0x8b, 0x58, 0x02, 0x00, 0x00,
// 339 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4e, 0xf2, 0x40,
0x10, 0xc7, 0xd9, 0x02, 0x1f, 0x74, 0x3e, 0x15, 0xdc, 0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, 0xf9, 0xdf, 0x3f, 0xee, 0xba, 0xe5, 0xbb, 0xd6, 0x68, 0xa6, 0x31, 0x6c, 0x3f,
0x7c, 0x4c, 0x87, 0xe6, 0xa6, 0x58, 0x0f, 0x4e, 0x0b, 0x35, 0x47, 0x0b, 0xa0, 0xee, 0xac, 0x65,
0x40, 0x3f, 0xdc, 0xe4, 0xfd, 0x4f, 0x04, 0xb5, 0x07, 0xc5, 0xc5, 0x50, 0x4b, 0x3c, 0x80, 0x7a,
0x7e, 0x0c, 0x4c, 0x36, 0x23, 0xf7, 0x8e, 0x1d, 0x9c, 0x1f, 0x50, 0xdc, 0xa0, 0x01, 0xd4, 0xf3,
0x55, 0x0a, 0x80, 0xbd, 0xc3, 0x15, 0x00, 0xbf, 0xf6, 0x1e, 0x81, 0xbf, 0xb1, 0x8f, 0x77, 0xfa,
0x76, 0xd6, 0x0c, 0x82, 0x43, 0x52, 0xc6, 0x18, 0xb5, 0x3f, 0x56, 0x14, 0x2d, 0x57, 0x14, 0x7d,
0xaf, 0x28, 0x7a, 0x5f, 0xd3, 0xd2, 0x72, 0x4d, 0x4b, 0x5f, 0x6b, 0x5a, 0x7a, 0x3e, 0x2a, 0xfe,
0x61, 0x2f, 0xff, 0xec, 0xeb, 0xe6, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x75, 0x8c, 0xa4, 0x78,
0x02, 0x00, 0x00,
}
func (m *DumpTreeRequest) Marshal() (dAtA []byte, err error) {

View File

@ -57,7 +57,7 @@ func (c *drpcNodeApiClient) DRPCConn() drpc.Conn { return c.cc }
func (c *drpcNodeApiClient) DumpTree(ctx context.Context, in *DumpTreeRequest) (*DumpTreeResponse, error) {
out := new(DumpTreeResponse)
err := c.cc.Invoke(ctx, "/api.NodeApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/nodeapi.NodeApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -66,7 +66,7 @@ func (c *drpcNodeApiClient) DumpTree(ctx context.Context, in *DumpTreeRequest) (
func (c *drpcNodeApiClient) AllTrees(ctx context.Context, in *AllTreesRequest) (*AllTreesResponse, error) {
out := new(AllTreesResponse)
err := c.cc.Invoke(ctx, "/api.NodeApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/nodeapi.NodeApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -75,7 +75,7 @@ func (c *drpcNodeApiClient) AllTrees(ctx context.Context, in *AllTreesRequest) (
func (c *drpcNodeApiClient) AllSpaces(ctx context.Context, in *AllSpacesRequest) (*AllSpacesResponse, error) {
out := new(AllSpacesResponse)
err := c.cc.Invoke(ctx, "/api.NodeApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
err := c.cc.Invoke(ctx, "/nodeapi.NodeApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out)
if err != nil {
return nil, err
}
@ -109,7 +109,7 @@ func (DRPCNodeApiDescription) NumMethods() int { return 3 }
func (DRPCNodeApiDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
switch n {
case 0:
return "/api.NodeApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/nodeapi.NodeApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCNodeApiServer).
DumpTree(
@ -118,7 +118,7 @@ func (DRPCNodeApiDescription) Method(n int) (string, drpc.Encoding, drpc.Receive
)
}, DRPCNodeApiServer.DumpTree, true
case 1:
return "/api.NodeApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/nodeapi.NodeApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCNodeApiServer).
AllTrees(
@ -127,7 +127,7 @@ func (DRPCNodeApiDescription) Method(n int) (string, drpc.Encoding, drpc.Receive
)
}, DRPCNodeApiServer.AllTrees, true
case 2:
return "/api.NodeApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{},
return "/nodeapi.NodeApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{},
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
return srv.(DRPCNodeApiServer).
AllSpaces(

View File

@ -1,5 +1,5 @@
syntax = "proto3";
package api;
package nodeapi;
option go_package = "api/apiproto";

View File

@ -13,15 +13,16 @@ const CName = "api.client"
var log = logger.NewNamed(CName)
type Service interface {
app.Component
CreateSpace(ctx context.Context, ip string, request *apiproto.CreateSpaceRequest) (resp *apiproto.CreateSpaceResponse, err error)
DeriveSpace(ctx context.Context, ip string, request *apiproto.DeriveSpaceRequest) (resp *apiproto.DeriveSpaceResponse, err error)
CreateDocument(ctx context.Context, ip string, request *apiproto.CreateDocumentRequest) (resp *apiproto.CreateDocumentResponse, err error)
DeleteDocument(ctx context.Context, ip string, request *apiproto.DeleteDocumentRequest) (resp *apiproto.DeleteDocumentResponse, err error)
AddText(ctx context.Context, ip string, request *apiproto.AddTextRequest) (resp *apiproto.AddTextResponse, err error)
DumpTree(ctx context.Context, ip string, request *apiproto.DumpTreeRequest) (resp *apiproto.DumpTreeResponse, err error)
AllTrees(ctx context.Context, ip string, request *apiproto.AllTreesRequest) (resp *apiproto.AllTreesResponse, err error)
AllSpaces(ctx context.Context, ip string, request *apiproto.AllSpacesRequest) (resp *apiproto.AllSpacesResponse, err error)
LoadSpace(ctx context.Context, ip string, request *apiproto.LoadSpaceRequest) (res *apiproto.LoadSpaceResponse, err error)
app.Component
}
type service struct {
@ -81,6 +82,14 @@ func (s *service) AddText(ctx context.Context, ip string, request *apiproto.AddT
return cl.AddText(ctx, request)
}
func (s *service) DumpTree(ctx context.Context, ip string, request *apiproto.DumpTreeRequest) (resp *apiproto.DumpTreeResponse, err error) {
cl, err := s.client.GetClient(ctx, ip)
if err != nil {
return
}
return cl.DumpTree(ctx, request)
}
func (s *service) AllTrees(ctx context.Context, ip string, request *apiproto.AllTreesRequest) (resp *apiproto.AllTreesResponse, err error) {
cl, err := s.client.GetClient(ctx, ip)
if err != nil {

View File

@ -1,8 +1,10 @@
package node
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/node/api/apiproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cmd/debug/drpcclient"
)
@ -12,6 +14,9 @@ var log = logger.NewNamed(CName)
type Service interface {
app.Component
DumpTree(ctx context.Context, ip string, request *apiproto.DumpTreeRequest) (resp *apiproto.DumpTreeResponse, err error)
AllTrees(ctx context.Context, ip string, request *apiproto.AllTreesRequest) (resp *apiproto.AllTreesResponse, err error)
AllSpaces(ctx context.Context, ip string, request *apiproto.AllSpacesRequest) (resp *apiproto.AllSpacesResponse, err error)
}
type service struct {
@ -30,3 +35,27 @@ func (s *service) Init(a *app.App) (err error) {
func (s *service) Name() (name string) {
return CName
}
func (s *service) DumpTree(ctx context.Context, ip string, request *apiproto.DumpTreeRequest) (resp *apiproto.DumpTreeResponse, err error) {
cl, err := s.client.GetNode(ctx, ip)
if err != nil {
return
}
return cl.DumpTree(ctx, request)
}
func (s *service) AllTrees(ctx context.Context, ip string, request *apiproto.AllTreesRequest) (resp *apiproto.AllTreesResponse, err error) {
cl, err := s.client.GetNode(ctx, ip)
if err != nil {
return
}
return cl.AllTrees(ctx, request)
}
func (s *service) AllSpaces(ctx context.Context, ip string, request *apiproto.AllSpacesRequest) (resp *apiproto.AllSpacesResponse, err error) {
cl, err := s.client.GetNode(ctx, ip)
if err != nil {
return
}
return cl.AllSpaces(ctx, request)
}

View File

@ -4,9 +4,10 @@ import (
"context"
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/client/api/apiproto"
clientproto "github.com/anytypeio/go-anytype-infrastructure-experiments/client/api/apiproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
nodeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/node/api/apiproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cmd/debug/api/client"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cmd/debug/api/node"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cmd/debug/peers"
@ -98,13 +99,12 @@ func (s *service) Call(server peers.Peer, cmdName string, params []string) (res
}
func (s *service) registerClientCommands() {
client := s.client
s.clientCommands["create-space"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 0 {
err = ErrIncorrectParamsCount
return
}
resp, err := client.CreateSpace(context.Background(), server.Address, &apiproto.CreateSpaceRequest{})
resp, err := s.client.CreateSpace(context.Background(), server.Address, &clientproto.CreateSpaceRequest{})
if err != nil {
return
}
@ -116,7 +116,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
resp, err := client.DeriveSpace(context.Background(), server.Address, &apiproto.DeriveSpaceRequest{})
resp, err := s.client.DeriveSpace(context.Background(), server.Address, &clientproto.DeriveSpaceRequest{})
if err != nil {
return
}
@ -128,7 +128,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
resp, err := client.CreateDocument(context.Background(), server.Address, &apiproto.CreateDocumentRequest{
resp, err := s.client.CreateDocument(context.Background(), server.Address, &clientproto.CreateDocumentRequest{
SpaceId: params[0],
})
if err != nil {
@ -142,7 +142,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
_, err = client.DeleteDocument(context.Background(), server.Address, &apiproto.DeleteDocumentRequest{
_, err = s.client.DeleteDocument(context.Background(), server.Address, &clientproto.DeleteDocumentRequest{
SpaceId: params[0],
DocumentId: params[1],
})
@ -157,7 +157,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
resp, err := client.AddText(context.Background(), server.Address, &apiproto.AddTextRequest{
resp, err := s.client.AddText(context.Background(), server.Address, &clientproto.AddTextRequest{
SpaceId: params[0],
DocumentId: params[1],
Text: params[2],
@ -173,7 +173,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
_, err = client.LoadSpace(context.Background(), server.Address, &apiproto.LoadSpaceRequest{
_, err = s.client.LoadSpace(context.Background(), server.Address, &clientproto.LoadSpaceRequest{
SpaceId: params[0],
})
if err != nil {
@ -187,7 +187,7 @@ func (s *service) registerClientCommands() {
err = ErrIncorrectParamsCount
return
}
resp, err := client.AllTrees(context.Background(), server.Address, &apiproto.AllTreesRequest{
resp, err := s.client.AllTrees(context.Background(), server.Address, &clientproto.AllTreesRequest{
SpaceId: params[0],
})
if err != nil {
@ -209,12 +209,27 @@ func (s *service) registerClientCommands() {
}
return
}}
s.clientCommands["dump-tree"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 2 {
err = ErrIncorrectParamsCount
return
}
resp, err := s.client.DumpTree(context.Background(), server.Address, &clientproto.DumpTreeRequest{
SpaceId: params[0],
DocumentId: params[1],
})
if err != nil {
return
}
res = resp.Dump
return
}}
s.clientCommands["all-spaces"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 0 {
err = ErrIncorrectParamsCount
return
}
resp, err := client.AllSpaces(context.Background(), server.Address, &apiproto.AllSpacesRequest{})
resp, err := s.client.AllSpaces(context.Background(), server.Address, &clientproto.AllSpacesRequest{})
if err != nil {
return
}
@ -229,6 +244,65 @@ func (s *service) registerClientCommands() {
}
func (s *service) registerNodeCommands() {
s.nodeCommands["all-trees"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 1 {
err = ErrIncorrectParamsCount
return
}
resp, err := s.node.AllTrees(context.Background(), server.Address, &nodeproto.AllTreesRequest{
SpaceId: params[0],
})
if err != nil {
return
}
for treeIdx, tree := range resp.Trees {
treeStr := tree.Id + ":["
for headIdx, head := range tree.Heads {
treeStr += head
if headIdx != len(tree.Heads)-1 {
treeStr += ","
}
}
treeStr += "]"
res += treeStr
if treeIdx != len(resp.Trees)-1 {
res += "\n"
}
}
return
}}
s.nodeCommands["dump-tree"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 2 {
err = ErrIncorrectParamsCount
return
}
resp, err := s.node.DumpTree(context.Background(), server.Address, &nodeproto.DumpTreeRequest{
SpaceId: params[0],
DocumentId: params[1],
})
if err != nil {
return
}
res = resp.Dump
return
}}
s.nodeCommands["all-spaces"] = Command{Cmd: func(server peers.Peer, params []string) (res string, err error) {
if len(params) != 0 {
err = ErrIncorrectParamsCount
return
}
resp, err := s.node.AllSpaces(context.Background(), server.Address, &nodeproto.AllSpacesRequest{})
if err != nil {
return
}
for treeIdx, spaceId := range resp.SpaceIds {
res += spaceId
if treeIdx != len(resp.SpaceIds)-1 {
res += "\n"
}
}
return
}}
}
func (s *service) registerScripts() {
@ -251,7 +325,7 @@ func (s *service) registerScripts() {
}
for i := 0; i < last; i++ {
_, err := s.client.AddText(context.Background(), peer.Address, &apiproto.AddTextRequest{
_, err := s.client.AddText(context.Background(), peer.Address, &clientproto.AddTextRequest{
SpaceId: params[1],
DocumentId: params[2],
Text: params[3],

View File

@ -2,18 +2,19 @@ package drpcclient
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/client/api/apiproto"
clientproto "github.com/anytypeio/go-anytype-infrastructure-experiments/client/api/apiproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/ocache"
nodeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/node/api/apiproto"
"net"
"storj.io/drpc/drpcconn"
"time"
)
type Service interface {
GetClient(ctx context.Context, ip string) (apiproto.DRPCClientApiClient, error)
GetNode(ctx context.Context, ip string) (apiproto.DRPCClientApiClient, error)
GetClient(ctx context.Context, ip string) (clientproto.DRPCClientApiClient, error)
GetNode(ctx context.Context, ip string) (nodeproto.DRPCNodeApiClient, error)
app.ComponentRunnable
}
@ -54,7 +55,7 @@ func (s *service) Run(ctx context.Context) (err error) {
return nil
}
func (s *service) GetClient(ctx context.Context, ip string) (apiproto.DRPCClientApiClient, error) {
func (s *service) GetClient(ctx context.Context, ip string) (clientproto.DRPCClientApiClient, error) {
v, err := s.cache.Get(ctx, ip)
if err != nil {
return nil, err
@ -63,13 +64,13 @@ func (s *service) GetClient(ctx context.Context, ip string) (apiproto.DRPCClient
select {
case <-conn.Closed():
default:
return apiproto.NewDRPCClientApiClient(conn), nil
return clientproto.NewDRPCClientApiClient(conn), nil
}
s.cache.Remove(ip)
return s.GetClient(ctx, ip)
}
func (s *service) GetNode(ctx context.Context, ip string) (apiproto.DRPCClientApiClient, error) {
func (s *service) GetNode(ctx context.Context, ip string) (nodeproto.DRPCNodeApiClient, error) {
v, err := s.cache.Get(ctx, ip)
if err != nil {
return nil, err
@ -78,11 +79,10 @@ func (s *service) GetNode(ctx context.Context, ip string) (apiproto.DRPCClientAp
select {
case <-conn.Closed():
default:
panic("should return node")
return apiproto.NewDRPCClientApiClient(conn), nil
return nodeproto.NewDRPCNodeApiClient(conn), nil
}
s.cache.Remove(ip)
return s.GetClient(ctx, ip)
return s.GetNode(ctx, ip)
}
func (s *service) Close(ctx context.Context) (err error) {

View File

@ -43,6 +43,10 @@ func (s *service) Init(a *app.App) (err error) {
PeerType: PeerTypeClient,
Address: "127.0.0.1:8091",
}
s.peerMap["node1"] = Peer{
PeerType: PeerTypeNode,
Address: "127.0.0.1:8080",
}
return
}