Skip to content

Commit

Permalink
Mispell2 (#106)
Browse files Browse the repository at this point in the history
* fix mispelling

* fix sanke case
  • Loading branch information
chemidy committed Mar 2, 2022
1 parent 0f6d2a1 commit 869cce3
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions pkg/auth/authmiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func ZincAuthMiddleware(c *gin.Context) {
}
}

func VerifyCredentials(userId, password string) (SimpleUser, bool) {
user, ok := ZINC_CACHED_USERS[userId]
func VerifyCredentials(userID, password string) (SimpleUser, bool) {
user, ok := ZINC_CACHED_USERS[userID]
if !ok {
return SimpleUser{}, false
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/createuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/prabhatsharma/zinc/pkg/core"
)

func CreateUser(userId, name, plaintextPassword, role string) (*ZincUser, error) {
func CreateUser(userID, name, plaintextPassword, role string) (*ZincUser, error) {
var newUser *ZincUser
existingUser, userExists, err := GetUser(userId)
existingUser, userExists, err := GetUser(userID)
if err != nil {
return nil, err
}
Expand All @@ -29,7 +29,7 @@ func CreateUser(userId, name, plaintextPassword, role string) (*ZincUser, error)
newUser.Timestamp = time.Now()
} else {
newUser = &ZincUser{
ID: userId,
ID: userID,
Name: name,
Role: role,
CreatedAt: time.Now(),
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/deleteuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/prabhatsharma/zinc/pkg/core"
)

func DeleteUser(userId string) bool {
bdoc := bluge.NewDocument(userId)
func DeleteUser(userID string) bool {
bdoc := bluge.NewDocument(userID)
bdoc.AddField(bluge.NewCompositeFieldExcluding("_all", nil))
usersIndexWriter := core.ZINC_SYSTEM_INDEX_LIST["_users"].Writer
err := usersIndexWriter.Delete(bdoc.ID())
Expand All @@ -18,7 +18,7 @@ func DeleteUser(userId string) bool {
}

// delete cache
delete(ZINC_CACHED_USERS, userId)
delete(ZINC_CACHED_USERS, userID)

return true
}
4 changes: 2 additions & 2 deletions pkg/auth/getuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/prabhatsharma/zinc/pkg/core"
)

func GetUser(userId string) (ZincUser, bool, error) {
func GetUser(userID string) (ZincUser, bool, error) {
userExists := false
var user ZincUser

query := bluge.NewTermQuery(userId)
query := bluge.NewTermQuery(userID)
searchRequest := bluge.NewTopNSearch(1, query)
reader, _ := core.ZINC_SYSTEM_INDEX_LIST["_users"].Writer.Reader()
dmi, err := reader.Search(context.Background(), searchRequest)
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ func (t *telemetry) getInstanceID() string {
func (t *telemetry) initBaseInfo() {
t.baseInfoOnce.Do(func() {
m, _ := mem.VirtualMemory()
cpu_count, _ := cpu.Counts(true)
cpuCount, _ := cpu.Counts(true)
zone, _ := time.Now().Local().Zone()

t.baseInfo = map[string]interface{}{
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"zinc_version": v1.Version,
"time_zone": zone,
"cpu_count": cpu_count,
"cpu_count": cpuCount,
"total_memory": m.Total / 1024 / 1024,
}
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/directory/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ func (s *S3Directory) Persist(kind string, id uint64, w index.WriterTo, closeCh
Body: bytes.NewReader(buf.Bytes()),
}

ouput, err := s.Client.PutObject(ctx, &params)
output, err := s.Client.PutObject(ctx, &params)

if err != nil {
log.Print("Persist: failed to write object: ", err.Error())
return err
}

log.Print("Persist: s3 object "+s.Bucket+"/"+path+" written. Its md5 hash is: ", *ouput.ETag) // TODO: compare md5 hashes here to ensure successful write
log.Print("Persist: s3 object "+s.Bucket+"/"+path+" written. Its md5 hash is: ", *output.ETag) // TODO: compare md5 hashes here to ensure successful write

return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/handlers/deletedocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (

func DeleteDocument(c *gin.Context) {
indexName := c.Param("target")
query_id := c.Param("id")
queryID := c.Param("id")

index, exists := core.GetIndex(indexName)
if !exists {
c.JSON(http.StatusBadRequest, gin.H{"error": "index does not exists"})
return
}

bdoc := bluge.NewDocument(query_id)
bdoc := bluge.NewDocument(queryID)
bdoc.AddField(bluge.NewCompositeFieldExcluding("_all", nil))
err := index.Writer.Delete(bdoc.ID())
if err != nil {
c.JSON(http.StatusInternalServerError, err)
} else {
c.JSON(http.StatusOK, gin.H{"message": "Deleted", "index": indexName, "id": query_id})
c.JSON(http.StatusOK, gin.H{"message": "Deleted", "index": indexName, "id": queryID})
}
}
14 changes: 7 additions & 7 deletions pkg/handlers/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func SearchIndex(c *gin.Context) {
return
}

event_data := make(map[string]interface{})
event_data["search_type"] = iQuery.SearchType
event_data["search_index_storage"] = index.StorageType
event_data["search_index_size_in_mb"] = core.Telemetry.GetIndexSize(indexName)
event_data["time_taken_to_search_in_ms"] = res.Took
event_data["aggregations_count"] = len(iQuery.Aggregations)
core.Telemetry.Event("search", event_data)
eventData := make(map[string]interface{})
eventData["search_type"] = iQuery.SearchType
eventData["search_index_storage"] = index.StorageType
eventData["search_index_size_in_mb"] = core.Telemetry.GetIndexSize(indexName)
eventData["time_taken_to_search_in_ms"] = res.Took
eventData["aggregations_count"] = len(iQuery.Aggregations)
core.Telemetry.Event("search", eventData)

c.JSON(http.StatusOK, res)
}
6 changes: 3 additions & 3 deletions pkg/handlers/updatedocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func UpdateDocument(c *gin.Context) {
indexName := c.Param("target")
query_id := c.Param("id") // ID for the document to be updated provided in URL path
queryID := c.Param("id") // ID for the document to be updated provided in URL path

var doc map[string]interface{}
if err := c.BindJSON(&doc); err != nil {
Expand All @@ -26,8 +26,8 @@ func UpdateDocument(c *gin.Context) {
// If id field is present then use it, else create a new UUID and use it
if id, ok := doc["_id"]; ok {
docID = id.(string)
} else if query_id != "" {
docID = query_id
} else if queryID != "" {
docID = queryID
}
if docID == "" {
docID = uuid.New().String() // Generate a new ID if ID was not provided
Expand Down
14 changes: 7 additions & 7 deletions pkg/handlers/v2/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func SearchIndex(c *gin.Context) {
return
}

event_data := make(map[string]interface{})
event_data["search_type"] = "query_dsl"
event_data["search_index_storage"] = storageType
event_data["search_index_size_in_mb"] = indexSize
event_data["time_taken_to_search_in_ms"] = resp.Took
event_data["aggregations_count"] = len(query.Aggregations)
core.Telemetry.Event("search", event_data)
eventData := make(map[string]interface{})
eventData["search_type"] = "query_dsl"
eventData["search_index_storage"] = storageType
eventData["search_index_size_in_mb"] = indexSize
eventData["time_taken_to_search_in_ms"] = resp.Took
eventData["aggregations_count"] = len(query.Aggregations)
core.Telemetry.Event("search", eventData)

c.JSON(http.StatusOK, resp)
}
Expand Down

0 comments on commit 869cce3

Please sign in to comment.