-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a basic SDK creation package. In part 1, we create the basic default implementations and provide initial SDK configuration/options. Change-Id: Ia839c3602be257d2ed979f0573a0b38d0e8cbc06 Signed-off-by: Troy Ronda <troy@troyronda.com>
- Loading branch information
Showing
6 changed files
with
388 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package fabapi | ||
|
||
import "testing" | ||
|
||
func TestNewDefaultSDK(t *testing.T) { | ||
|
||
setup := Options{ | ||
ConfigFile: "../../test/fixtures/config/config_test.yaml", | ||
OrgID: "org1", | ||
StateStoreOpts: StateStoreOpts{ | ||
Path: "/tmp/state", | ||
}, | ||
} | ||
|
||
_, err := NewSDK(setup) | ||
if err != nil { | ||
t.Fatalf("Error initializing SDK: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package fabapi | ||
|
||
import ( | ||
"github.com/hyperledger/fabric-sdk-go/api/apiconfig" | ||
fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient" | ||
) | ||
|
||
// SDKOpts provides bootstrap setup | ||
type SDKOpts struct { | ||
ConfigFile string | ||
} | ||
|
||
// ConfigOpts provides setup parameters for Config | ||
type ConfigOpts struct { // TODO (moved ConfigFile to SDKOpts to make setup easier for API consumer) | ||
} | ||
|
||
// StateStoreOpts provides setup parameters for KeyValueStore | ||
type StateStoreOpts struct { | ||
Path string | ||
} | ||
|
||
// NewDefaultConfig creates a Config using the SDK's default implementation | ||
func NewDefaultConfig(o ConfigOpts, a SDKOpts) (apiconfig.Config, error) { | ||
return NewConfigManager(a.ConfigFile) | ||
} | ||
|
||
// NewDefaultStateStore creates a KeyValueStore using the SDK's default implementation | ||
func NewDefaultStateStore(o StateStoreOpts, config apiconfig.Config) (fab.KeyValueStore, error) { | ||
return NewKVStore(o.Path) // TODO: config should have this capability | ||
} |
Oops, something went wrong.