aries

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 22 Imported by: 30

Documentation

Overview

Package aries provides a pluggable dependency framework, where implementors can customize primitives via Service Provider Interfaces (SPIs). The framework comes with a "batteries included" model where default primitives are included. The framework holds a context that can be used to create aries clients.

Usage:

// create the framework
framework := aries.New()

// get the context
ctx := framework.Context()

// initialize the aries clients
didexchangeClient, err := didexchange.New(ctx)
Example
package main

import (
	"fmt"

	"github.com/hyperledger/aries-framework-go/pkg/didcomm/transport"
	"github.com/hyperledger/aries-framework-go/pkg/storage"
)

func main() {
	// create the framework with user options
	framework, err := New(
		WithInboundTransport(newMockInTransport()),
		WithStoreProvider(newMockDBProvider()),
		WithTransientStoreProvider(newMockDBProvider()),
	)
	if err != nil {
		fmt.Println("failed to create framework")
	}

	// get the context from the framework
	ctx, err := framework.Context()
	if err != nil {
		fmt.Println("failed to create framework context")
	}

	fmt.Println("context created successfully")
	fmt.Println(ctx.InboundTransportEndpoint())

}

// mock inbound transport
type mockInTransport struct {
}

func newMockInTransport() *mockInTransport {
	return &mockInTransport{}
}

func (c *mockInTransport) Start(prov transport.InboundProvider) error {
	return nil
}

func (c *mockInTransport) Stop() error {
	return nil
}
func (c *mockInTransport) Endpoint() string {
	return "http://server"
}

// mock DB provider
type mockDBProvider struct {
}

func newMockDBProvider() *mockDBProvider {
	return &mockDBProvider{}
}

func (c *mockDBProvider) OpenStore(name string) (storage.Store, error) {
	return nil, nil
}

func (c *mockDBProvider) CloseStore(name string) error {
	return nil
}
func (c *mockDBProvider) Close() error {
	return nil
}
Output:

context created successfully
http://server

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aries

type Aries struct {
	// contains filtered or unexported fields
}

Aries provides access to the context being managed by the framework. The context can be used to create aries clients.

func New

func New(opts ...Option) (*Aries, error)

New initializes the Aries framework based on the set of options provided. This function returns a framework which can be used to manage Aries clients by getting the framework context.

func (*Aries) Close

func (a *Aries) Close() error

Close frees resources being maintained by the framework.

func (*Aries) Context

func (a *Aries) Context() (*context.Provider, error)

Context provides a handle to the framework context.

type Option

type Option func(opts *Aries) error

Option configures the framework.

func WithDIDResolver

func WithDIDResolver(didResolver didresolver.Resolver) Option

WithDIDResolver injects a DID resolver to the Aries framework.

func WithDIDStore

func WithDIDStore(didStore didstore.Storage) Option

WithDIDStore injects a DID store to the Aries framework.

func WithInboundTransport

func WithInboundTransport(inboundTransport transport.InboundTransport) Option

WithInboundTransport injects an inbound transport to the Aries framework.

func WithKMS

func WithKMS(k api.KMSCreator) Option

WithKMS injects a KMS service to the Aries framework.

func WithOutboundDispatcher

func WithOutboundDispatcher(o dispatcher.OutboundCreator) Option

WithOutboundDispatcher injects an outbound dispatcher service to the Aries framework.

func WithOutboundTransport

func WithOutboundTransport(outboundTransport transport.OutboundTransport) Option

WithOutboundTransport injects an outbound transport to the Aries framework.

func WithPacker

func WithPacker(primary packer.Creator, additionalPackers ...packer.Creator) Option

WithPacker injects at least one Packer service into the Aries framework, with the primary Packer being used for inbound/outbound communication and the additional packers being available for unpacking inbound messages.

func WithProtocols

func WithProtocols(protocolSvcCreator ...api.ProtocolSvcCreator) Option

WithProtocols injects a protocol service to the Aries framework.

func WithStoreProvider

func WithStoreProvider(prov storage.Provider) Option

WithStoreProvider injects a storage provider to the Aries framework.

func WithTransientStoreProvider

func WithTransientStoreProvider(prov storage.Provider) Option

WithTransientStoreProvider injects a transient storage provider to the Aries framework.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL