Skip to content

API adds context in building blocks. #1601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1046102779 opened this issue Mar 18, 2022 · 6 comments
Closed

API adds context in building blocks. #1601

1046102779 opened this issue Mar 18, 2022 · 6 comments
Labels

Comments

@1046102779
Copy link
Member

1046102779 commented Mar 18, 2022

Whether the building blocks standard API should add context to transmit timeout mechanism, trace and other information? I think it is very necessary.

image

I think the way of handling is unfriendly. It is very necessary to add context to the network transmission. At the same time, we can pass the context information to the downstream, so that the entire trace link can be formed with the downstream. a trace link should not be only exist in dapr cluster.

But component.type= configuration exists context, API definitions are not consistent.

// Store is an interface to perform operations on store.
type Store interface {
	// Init configuration store.
	Init(metadata Metadata) error

	// Get configuration.
	Get(ctx context.Context, req *GetRequest) (*GetResponse, error)

	// Subscribe configuration by update event.
	Subscribe(ctx context.Context, req *SubscribeRequest, handler UpdateHandler) (string, error)

	// Unsubscribe configuration with keys
	Unsubscribe(ctx context.Context, req *UnsubscribeRequest) error
}
@1046102779
Copy link
Member Author

1046102779 commented Mar 18, 2022

  1. Binding: Change from OutputBinding interface
// OutputBinding is the interface for an output binding, allowing users to invoke remote systems with optional payloads.
type OutputBinding interface {
	Init(metadata Metadata) error
	Invoke(req *InvokeRequest) (*InvokeResponse, error)
	Operations() []OperationKind
}

to

// OutputBinding is the interface for an output binding, allowing users to invoke remote systems with optional payloads.
type OutputBinding interface {
	Init(metadata Metadata) error
	Invoke(ctx context.Context, req *InvokeRequest) (*InvokeResponse, error)
	Operations() []OperationKind
}

Binding: Change from InputBinding interface.

// InputBinding is the interface to define a binding that triggers on incoming events.
type InputBinding interface {
        // Init passes connection and properties metadata to the binding implementation
        Init(metadata Metadata) error
        // Read is a blocking method that triggers the callback function whenever an event arrives
        Read(handler func(*ReadResponse) ([]byte, error)) error
}

to

// InputBinding is the interface to define a binding that triggers on incoming events.
type InputBinding interface {
        // Init passes connection and properties metadata to the binding implementation
        Init(metadata Metadata) error
        // Read is a blocking method that triggers the callback function whenever an event arrives
        Read(handler func(context.Context, *ReadResponse) ([]byte, error)) error
}
  1. State: Change from Store And BulkStore interface
// Store is an interface to perform operations on store.
type Store interface {
	BulkStore
	Init(metadata Metadata) error
	Features() []Feature
	Delete(req *DeleteRequest) error
	Get(req *GetRequest) (*GetResponse, error)
	Set(req *SetRequest) error
	Ping() error
}

// BulkStore is an interface to perform bulk operations on store.
type BulkStore interface {
	BulkDelete(req []DeleteRequest) error
	BulkGet(req []GetRequest) (bool, []BulkGetResponse, error)
	BulkSet(req []SetRequest) error
}

to

// Store is an interface to perform operations on store.
type Store interface {
	BulkStore
	Init(metadata Metadata) error
	Features() []Feature
	Delete(ctx context.Context, req *DeleteRequest) error
	Get(ctx context.Context, req *GetRequest) (*GetResponse, error)
	Set(ctx context.Context, req *SetRequest) error
	Ping(ctx context.Context) error
}

// BulkStore is an interface to perform bulk operations on store.
type BulkStore interface {
	BulkDelete(ctx context.Context, req []DeleteRequest) error
	BulkGet(ctx context.Context, req []GetRequest) (bool, []BulkGetResponse, error)
	BulkSet(ctx context.Context, req []SetRequest) error
}

state.query: Change from Querier interface

// Querier is an interface to execute queries.
type Querier interface {
        Query(req *QueryRequest) (*QueryResponse, error)
}

to

// Querier is an interface to execute queries.
type Querier interface {
        Query(ctx context.Context, req *QueryRequest) (*QueryResponse, error)
}

Change from TransactionalStore API

// TransactionalStore is an interface for initialization and support multiple transactional requests.
type TransactionalStore interface {
        Init(metadata Metadata) error
        Multi(request *TransactionalStateRequest) error
}

to

// TransactionalStore is an interface for initialization and support multiple transactional requests.
type TransactionalStore interface {
        Init(metadata Metadata) error
        Multi(ctx context.Context, request *TransactionalStateRequest) error
}
  1. SecretStore: Change from SecretStore interface
// SecretStore is the interface for a component that handles secrets management.
type SecretStore interface {
	// Init authenticates with the actual secret store and performs other init operation
	Init(metadata Metadata) error
	// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
	GetSecret(req GetSecretRequest) (GetSecretResponse, error)
	// BulkGetSecrets retrieves all secrets in the store and returns a map of decrypted string/string values
	BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
}

to

// SecretStore is the interface for a component that handles secrets management.
type SecretStore interface {
	// Init authenticates with the actual secret store and performs other init operation
	Init(metadata Metadata) error
	// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
	GetSecret(ctx context.Context, req GetSecretRequest) (GetSecretResponse, error)
	// BulkGetSecrets retrieves all secrets in the store and returns a map of decrypted string/string values
	BulkGetSecret(ctx context.Context, req BulkGetSecretRequest) (BulkGetSecretResponse, error)
}
  1. PubSub: Change from PubSub interface
// PubSub is the interface for message buses.
type PubSub interface {
	Init(metadata Metadata) error
	Features() []Feature
	Publish(req *PublishRequest) error
	Subscribe(req SubscribeRequest, handler Handler) error
	Close() error
}

to

// PubSub is the interface for message buses.
type PubSub interface {
	Init(metadata Metadata) error
	Features() []Feature
	Publish(ctx context.Context, req *PublishRequest) error
	Subscribe(ctx context.Context, req SubscribeRequest, handler Handler) error
	Close() error
}
  1. NameResolution: Change from Resolver interface
// Resolver is the interface of name resolver.
type Resolver interface {
	// Init initializes name resolver.
	Init(metadata Metadata) error
	// ResolveID resolves name to address.
	ResolveID(req ResolveRequest) (string, error)
}

to

// Resolver is the interface of name resolver.
type Resolver interface {
	// Init initializes name resolver.
	Init(metadata Metadata) error
	// ResolveID resolves name to address.
	ResolveID(ctx context.Context, req ResolveRequest) (string, error)
}

@1046102779 1046102779 changed the title Abstract API adds context in building blocks. API adds context in building blocks. Mar 18, 2022
@1046102779
Copy link
Member Author

@yaron2 @artursouza @daixiang0 /cc

@daixiang0
Copy link
Member

Agree, it will bring full link tracking.

@pigletfly
Copy link
Contributor

related dapr/dapr#2716

@dapr-bot
Copy link
Collaborator

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

@dapr-bot dapr-bot added the stale label May 24, 2022
@dapr-bot
Copy link
Collaborator

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants