diff --git a/README.md b/README.md index 63bdfdf..6eae47c 100644 --- a/README.md +++ b/README.md @@ -228,11 +228,11 @@ func TestGetAllowedRecordsForUser(t *testing.T) { `gormadapter` supports adapter with context, the following is a timeout control implemented using context ```go -ca, _ := NewContextAdapter("mysql", "root:@tcp(127.0.0.1:3306)/", "casbin") +a, _ := gormadapter.NewAdapter("mysql", "mysql_username:mysql_password@tcp(127.0.0.1:3306)/") // Your driver and data source. // Limited time 300s ctx, cancel := context.WithTimeout(context.Background(), 300*time.Microsecond) defer cancel() -err := ca.AddPolicyCtx(ctx, "p", "p", []string{"alice", "data1", "read"}) +err := a.AddPolicyCtx(ctx, "p", "p", []string{"alice", "data1", "read"}) if err != nil { panic(err) } diff --git a/context_adapter.go b/context_adapter.go deleted file mode 100644 index efcd654..0000000 --- a/context_adapter.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 The casbin Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package gormadapter - -// Deprecated: Use Adapter instead. -type ContextAdapter struct { - *Adapter -} - -func NewContextAdapter(driverName string, dataSourceName string, params ...interface{}) (*ContextAdapter, error) { - a, err := NewAdapter(driverName, dataSourceName, params...) - return &ContextAdapter{ - a, - }, err -}