feature/1125 offload sync service worker (#1144)

- **feat: provide access to block time**
- **refactor: move block expiry calculation to helper function**
- **feat: register decentralized web node HTMX views**
- **feat: Reorganize methods in layout.templ file alphabetically**
- **feat: add support for layout variants**
- **feat: update Allocate RPC to use GET request with path parameters**
- **feat: add gRPC Gateway endpoint for Allocate**
- **refactor: rename SyncCurrent to Sync**
- **feat: improve code organization by making vault assembly private**
- **feat: add a new method for syncing DID documents**
This commit is contained in:
Prad Nukala
2024-10-18 13:07:52 -04:00
committed by GitHub
parent c2f7a53017
commit 2cd44c0b66
23 changed files with 571 additions and 4641 deletions
+225 -1410
View File
File diff suppressed because it is too large Load Diff
+18 -59
View File
@@ -19,11 +19,10 @@ import (
const _ = grpc.SupportPackageIsVersion7
const (
Query_Params_FullMethodName = "/vault.v1.Query/Params"
Query_Schema_FullMethodName = "/vault.v1.Query/Schema"
Query_Allocate_FullMethodName = "/vault.v1.Query/Allocate"
Query_SyncInitial_FullMethodName = "/vault.v1.Query/SyncInitial"
Query_SyncCurrent_FullMethodName = "/vault.v1.Query/SyncCurrent"
Query_Params_FullMethodName = "/vault.v1.Query/Params"
Query_Schema_FullMethodName = "/vault.v1.Query/Schema"
Query_Allocate_FullMethodName = "/vault.v1.Query/Allocate"
Query_Sync_FullMethodName = "/vault.v1.Query/Sync"
)
// QueryClient is the client API for Query service.
@@ -40,10 +39,7 @@ type QueryClient interface {
Allocate(ctx context.Context, in *AllocateRequest, opts ...grpc.CallOption) (*AllocateResponse, error)
// Sync queries the DID document by its id. And returns the required PKL
// information
SyncInitial(ctx context.Context, in *SyncInitialRequest, opts ...grpc.CallOption) (*SyncInitialResponse, error)
// SyncCurrent queries the DID document by its id. And returns the required PKL
// information
SyncCurrent(ctx context.Context, in *SyncCurrentRequest, opts ...grpc.CallOption) (*SyncCurrentResponse, error)
Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (*SyncResponse, error)
}
type queryClient struct {
@@ -81,18 +77,9 @@ func (c *queryClient) Allocate(ctx context.Context, in *AllocateRequest, opts ..
return out, nil
}
func (c *queryClient) SyncInitial(ctx context.Context, in *SyncInitialRequest, opts ...grpc.CallOption) (*SyncInitialResponse, error) {
out := new(SyncInitialResponse)
err := c.cc.Invoke(ctx, Query_SyncInitial_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *queryClient) SyncCurrent(ctx context.Context, in *SyncCurrentRequest, opts ...grpc.CallOption) (*SyncCurrentResponse, error) {
out := new(SyncCurrentResponse)
err := c.cc.Invoke(ctx, Query_SyncCurrent_FullMethodName, in, out, opts...)
func (c *queryClient) Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (*SyncResponse, error) {
out := new(SyncResponse)
err := c.cc.Invoke(ctx, Query_Sync_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
@@ -113,10 +100,7 @@ type QueryServer interface {
Allocate(context.Context, *AllocateRequest) (*AllocateResponse, error)
// Sync queries the DID document by its id. And returns the required PKL
// information
SyncInitial(context.Context, *SyncInitialRequest) (*SyncInitialResponse, error)
// SyncCurrent queries the DID document by its id. And returns the required PKL
// information
SyncCurrent(context.Context, *SyncCurrentRequest) (*SyncCurrentResponse, error)
Sync(context.Context, *SyncRequest) (*SyncResponse, error)
mustEmbedUnimplementedQueryServer()
}
@@ -133,11 +117,8 @@ func (UnimplementedQueryServer) Schema(context.Context, *QuerySchemaRequest) (*Q
func (UnimplementedQueryServer) Allocate(context.Context, *AllocateRequest) (*AllocateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Allocate not implemented")
}
func (UnimplementedQueryServer) SyncInitial(context.Context, *SyncInitialRequest) (*SyncInitialResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SyncInitial not implemented")
}
func (UnimplementedQueryServer) SyncCurrent(context.Context, *SyncCurrentRequest) (*SyncCurrentResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SyncCurrent not implemented")
func (UnimplementedQueryServer) Sync(context.Context, *SyncRequest) (*SyncResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Sync not implemented")
}
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
@@ -206,38 +187,20 @@ func _Query_Allocate_Handler(srv interface{}, ctx context.Context, dec func(inte
return interceptor(ctx, in, info, handler)
}
func _Query_SyncInitial_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncInitialRequest)
func _Query_Sync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).SyncInitial(ctx, in)
return srv.(QueryServer).Sync(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Query_SyncInitial_FullMethodName,
FullMethod: Query_Sync_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).SyncInitial(ctx, req.(*SyncInitialRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Query_SyncCurrent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncCurrentRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).SyncCurrent(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Query_SyncCurrent_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).SyncCurrent(ctx, req.(*SyncCurrentRequest))
return srv.(QueryServer).Sync(ctx, req.(*SyncRequest))
}
return interceptor(ctx, in, info, handler)
}
@@ -262,12 +225,8 @@ var Query_ServiceDesc = grpc.ServiceDesc{
Handler: _Query_Allocate_Handler,
},
{
MethodName: "SyncInitial",
Handler: _Query_SyncInitial_Handler,
},
{
MethodName: "SyncCurrent",
Handler: _Query_SyncCurrent_Handler,
MethodName: "Sync",
Handler: _Query_Sync_Handler,
},
},
Streams: []grpc.StreamDesc{},
+43 -1350
View File
File diff suppressed because it is too large Load Diff
+1 -44
View File
@@ -19,18 +19,13 @@ import (
const _ = grpc.SupportPackageIsVersion7
const (
Msg_AllocateVault_FullMethodName = "/vault.v1.Msg/AllocateVault"
Msg_UpdateParams_FullMethodName = "/vault.v1.Msg/UpdateParams"
Msg_UpdateParams_FullMethodName = "/vault.v1.Msg/UpdateParams"
)
// MsgClient is the client API for Msg service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MsgClient interface {
// AllocateVault assembles a sqlite3 database in a local directory and returns
// the CID of the database. this operation is called by services initiating a
// controller registration.
AllocateVault(ctx context.Context, in *MsgAllocateVault, opts ...grpc.CallOption) (*MsgAllocateVaultResponse, error)
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
@@ -45,15 +40,6 @@ func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) AllocateVault(ctx context.Context, in *MsgAllocateVault, opts ...grpc.CallOption) (*MsgAllocateVaultResponse, error) {
out := new(MsgAllocateVaultResponse)
err := c.cc.Invoke(ctx, Msg_AllocateVault_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, opts...)
@@ -67,10 +53,6 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
type MsgServer interface {
// AllocateVault assembles a sqlite3 database in a local directory and returns
// the CID of the database. this operation is called by services initiating a
// controller registration.
AllocateVault(context.Context, *MsgAllocateVault) (*MsgAllocateVaultResponse, error)
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
@@ -82,9 +64,6 @@ type MsgServer interface {
type UnimplementedMsgServer struct {
}
func (UnimplementedMsgServer) AllocateVault(context.Context, *MsgAllocateVault) (*MsgAllocateVaultResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AllocateVault not implemented")
}
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
@@ -101,24 +80,6 @@ func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
s.RegisterService(&Msg_ServiceDesc, srv)
}
func _Msg_AllocateVault_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgAllocateVault)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).AllocateVault(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Msg_AllocateVault_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).AllocateVault(ctx, req.(*MsgAllocateVault))
}
return interceptor(ctx, in, info, handler)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
@@ -144,10 +105,6 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
ServiceName: "vault.v1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AllocateVault",
Handler: _Msg_AllocateVault_Handler,
},
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,