Skip to content

Commit

Permalink
Merge pull request #61 from tianxiaoliang/main
Browse files Browse the repository at this point in the history
add new runtime interface
  • Loading branch information
tianxiaoliang authored Aug 15, 2022
2 parents b54632a + f7c980e commit 2c62cc5
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/db-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.18
id: go
- name: Check out source code
uses: actions/checkout@v1
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.18
id: go
- name: Check out source code
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.45.2
version: v1.48.0
args: --skip-dirs=discovery --skip-files=.*_test.go$
4 changes: 2 additions & 2 deletions .github/workflows/static_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.18
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
Expand Down
7 changes: 7 additions & 0 deletions codec/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package codec

// Codec declares encode and decode functions
type Codec interface {
Encode(v any) ([]byte, error)
Decode(data []byte, v any) error
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package config

//KVDoc is database struct to store kv
// KVDoc is database struct to store kv
type KVDoc struct {
ID string `json:"id,omitempty" bson:"id,omitempty" yaml:"id,omitempty" swag:"string"`
LabelFormat string `json:"label_format,omitempty" bson:"label_format,omitempty" yaml:"label_format,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/go-chassis/cari

go 1.17
go 1.18

require (
github.com/deckarep/golang-set v1.7.1
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
4 changes: 2 additions & 2 deletions rbac/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ type PersistPerms func(r *Role) error

var permsCache = ccache.New(ccache.Configure())

//WritePerms save cache
// WritePerms save cache
func WritePerms(r *Role) error {
permsCache.Set(r.Name, r, DefaultTTL)
return nil
}

//ReadPerms only return data in cache
// ReadPerms only return data in cache
func ReadPerms(roleName string) ([]*Permission, error) {
item := permsCache.Get(roleName)
if item == nil || item.Value() == nil {
Expand Down
2 changes: 1 addition & 1 deletion rbac/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func GetRolesList(m map[string]interface{}) ([]string, error) {
return roleList, nil
}

//BuildResourceList join the resource to an array
// BuildResourceList join the resource to an array
func BuildResourceList(resourceType ...string) []*Resource {
rt := make([]*Resource, len(resourceType))
for i := 0; i < len(resourceType); i++ {
Expand Down
10 changes: 5 additions & 5 deletions rbac/resource_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"sync"
)

//as a user of a backend service, he only understands resource of this service,
//to decouple authorization code from business code,
//a middleware should handle all the authorization logic, and this middleware only understand rest API,
//a resource mapping helps to maintain relations between api and resource.
// as a user of a backend service, he only understands resource of this service,
// to decouple authorization code from business code,
// a middleware should handle all the authorization logic, and this middleware only understand rest API,
// a resource mapping helps to maintain relations between api and resource.
var resourceMap = sync.Map{}

//PartialMap saves api partial matching
// PartialMap saves api partial matching
var PartialMap = map[string]string{}

// GetResource try to find resource by API path, it has preheat mechanism after program start up
Expand Down
2 changes: 1 addition & 1 deletion security/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Package security created on 2017/6/22
package security

//Cipher interface declares two function for encryption and decryption
// Cipher interface declares two function for encryption and decryption
type Cipher interface {
Encrypt(src string) (string, error)

Expand Down

0 comments on commit 2c62cc5

Please sign in to comment.