-
Notifications
You must be signed in to change notification settings - Fork 23
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
File References Pagination #273
Changes from 8 commits
8c8745a
0f78ff0
26a6e08
1ebd977
0badb03
6cee082
2199d14
adab8a6
21d3af8
937c196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/blobbergrpc" | ||
"github.com/0chain/blobber/code/go/0chain.net/core/common" | ||
"github.com/gorilla/mux" | ||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func registerGRPCServices(r *mux.Router, server *grpc.Server) { | ||
blobberService := newGRPCBlobberService() | ||
grpcGatewayHandler := runtime.NewServeMux() | ||
|
||
blobbergrpc.RegisterBlobberServer(server, blobberService) | ||
_ = blobbergrpc.RegisterBlobberHandlerServer(context.Background(), grpcGatewayHandler, blobberService) | ||
r.PathPrefix("/").Handler(grpcGatewayHandler) | ||
|
||
} | ||
|
||
func checkValidDate(s string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about Timezone? it will be an issue if client send date with local time zone. |
||
if s != "" { | ||
_, err := time.Parse("2006-01-02 15:04:05.999999999", s) | ||
if err != nil { | ||
return common.NewError("invalid_parameters", err.Error()) | ||
} | ||
} | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,40 +56,40 @@ func (a *Attributes) Validate() (err error) { | |
} | ||
|
||
type Ref struct { | ||
ID int64 `gorm:"column:id;primary_key"` | ||
Type string `gorm:"column:type" dirlist:"type" filelist:"type"` | ||
AllocationID string `gorm:"column:allocation_id"` | ||
LookupHash string `gorm:"column:lookup_hash" dirlist:"lookup_hash" filelist:"lookup_hash"` | ||
Name string `gorm:"column:name" dirlist:"name" filelist:"name"` | ||
Path string `gorm:"column:path" dirlist:"path" filelist:"path"` | ||
Hash string `gorm:"column:hash" dirlist:"hash" filelist:"hash"` | ||
NumBlocks int64 `gorm:"column:num_of_blocks" dirlist:"num_of_blocks" filelist:"num_of_blocks"` | ||
PathHash string `gorm:"column:path_hash" dirlist:"path_hash" filelist:"path_hash"` | ||
ParentPath string `gorm:"column:parent_path"` | ||
PathLevel int `gorm:"column:level"` | ||
CustomMeta string `gorm:"column:custom_meta" filelist:"custom_meta"` | ||
ContentHash string `gorm:"column:content_hash" filelist:"content_hash"` | ||
Size int64 `gorm:"column:size" dirlist:"size" filelist:"size"` | ||
MerkleRoot string `gorm:"column:merkle_root" filelist:"merkle_root"` | ||
ActualFileSize int64 `gorm:"column:actual_file_size" filelist:"actual_file_size"` | ||
ActualFileHash string `gorm:"column:actual_file_hash" filelist:"actual_file_hash"` | ||
MimeType string `gorm:"column:mimetype" filelist:"mimetype"` | ||
WriteMarker string `gorm:"column:write_marker"` | ||
ThumbnailSize int64 `gorm:"column:thumbnail_size" filelist:"thumbnail_size"` | ||
ThumbnailHash string `gorm:"column:thumbnail_hash" filelist:"thumbnail_hash"` | ||
ActualThumbnailSize int64 `gorm:"column:actual_thumbnail_size" filelist:"actual_thumbnail_size"` | ||
ActualThumbnailHash string `gorm:"column:actual_thumbnail_hash" filelist:"actual_thumbnail_hash"` | ||
EncryptedKey string `gorm:"column:encrypted_key" filelist:"encrypted_key"` | ||
Attributes datatypes.JSON `gorm:"column:attributes" filelist:"attributes"` | ||
Children []*Ref `gorm:"-"` | ||
childrenLoaded bool | ||
|
||
OnCloud bool `gorm:"column:on_cloud" filelist:"on_cloud"` | ||
CommitMetaTxns []CommitMetaTxn `gorm:"foreignkey:ref_id" filelist:"commit_meta_txns"` | ||
CreatedAt time.Time `gorm:"column:created_at" dirlist:"created_at" filelist:"created_at"` | ||
UpdatedAt time.Time `gorm:"column:updated_at" dirlist:"updated_at" filelist:"updated_at"` | ||
|
||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"` // soft deletion | ||
ID int64 `gorm:"column:id;primary_key" json:"id,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why add json annotations explicitly? Gorm handles the json naming imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It gives flexibility and also I am not sure about Gorm handling json naming. It supports json dataTypes but it always fills struct fields with its value and its easy to use it with json tag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. json column field is used when we unmarshal an interface to the following dataType, but since we already have gorm annotation, gorm has default serialising strategy as |
||
Type string `gorm:"column:type" dirlist:"type" filelist:"type" json:"type,omitempty"` | ||
lpoli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AllocationID string `gorm:"column:allocation_id" json:"allocation_id,omitempty"` | ||
LookupHash string `gorm:"column:lookup_hash" dirlist:"lookup_hash" filelist:"lookup_hash" json:"lookup_hash,omitempty"` | ||
Name string `gorm:"column:name" dirlist:"name" filelist:"name" json:"name,omitempty"` | ||
Path string `gorm:"column:path" dirlist:"path" filelist:"path" json:"path,omitempty"` | ||
Hash string `gorm:"column:hash" dirlist:"hash" filelist:"hash" json:"hash,omitempty"` | ||
NumBlocks int64 `gorm:"column:num_of_blocks" dirlist:"num_of_blocks" filelist:"num_of_blocks" json:"num_blocks,omitempty"` | ||
PathHash string `gorm:"column:path_hash" dirlist:"path_hash" filelist:"path_hash" json:"path_hash,omitempty"` | ||
ParentPath string `gorm:"column:parent_path" json:"parent_path,omitempty"` | ||
PathLevel int `gorm:"column:level" json:"level,omitempty"` | ||
CustomMeta string `gorm:"column:custom_meta" filelist:"custom_meta" json:"custom_meta,omitempty"` | ||
ContentHash string `gorm:"column:content_hash" filelist:"content_hash" json:"content_hash,omitempty"` | ||
Size int64 `gorm:"column:size" dirlist:"size" filelist:"size" json:"size,omitempty"` | ||
MerkleRoot string `gorm:"column:merkle_root" filelist:"merkle_root" json:"merkle_root,omitempty"` | ||
ActualFileSize int64 `gorm:"column:actual_file_size" filelist:"actual_file_size" json:"actual_file_size,omitempty"` | ||
ActualFileHash string `gorm:"column:actual_file_hash" filelist:"actual_file_hash" json:"actual_file_hash,omitempty"` | ||
MimeType string `gorm:"column:mimetype" filelist:"mimetype" json:"mimetype,omitempty"` | ||
WriteMarker string `gorm:"column:write_marker" json:"write_marker,omitempty"` | ||
ThumbnailSize int64 `gorm:"column:thumbnail_size" filelist:"thumbnail_size" json:"thumbnail_size,omitempty"` | ||
ThumbnailHash string `gorm:"column:thumbnail_hash" filelist:"thumbnail_hash" json:"thumbnail_hash,omitempty"` | ||
ActualThumbnailSize int64 `gorm:"column:actual_thumbnail_size" filelist:"actual_thumbnail_size" json:"actual_thumbnail_size,omitempty"` | ||
ActualThumbnailHash string `gorm:"column:actual_thumbnail_hash" filelist:"actual_thumbnail_hash" json:"actual_thumbnail_hash,omitempty"` | ||
EncryptedKey string `gorm:"column:encrypted_key" filelist:"encrypted_key" json:"encrypted_key,omitempty"` | ||
Attributes datatypes.JSON `gorm:"column:attributes" filelist:"attributes" json:"attributes,omitempty"` | ||
Children []*Ref `gorm:"-" json:"-"` | ||
childrenLoaded bool `json:"-"` | ||
|
||
OnCloud bool `gorm:"column:on_cloud" filelist:"on_cloud" json:"on_cloud,omitempty"` | ||
CommitMetaTxns []CommitMetaTxn `gorm:"foreignkey:ref_id" filelist:"commit_meta_txns" json:"-"` | ||
CreatedAt time.Time `gorm:"column:created_at" dirlist:"created_at" filelist:"created_at" json:"created_at,omitempty"` | ||
UpdatedAt time.Time `gorm:"column:updated_at" dirlist:"updated_at" filelist:"updated_at" json:"updated_at,omitempty"` | ||
|
||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"-"` // soft deletion | ||
} | ||
|
||
func (Ref) TableName() string { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add some documentation about what is NewOffsetPath/NewoffsetDate? it is confused there without any comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_pages
is snake_case, and offsetPath is lower_case. should we use snake_case only?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the field name is NewOffsetPath, but it is
offsetPath
in json. why they are different?