Skip to content
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

feat: sfn support init function #572

Closed
wants to merge 17 commits into from
Closed

feat: sfn support init function #572

wants to merge 17 commits into from

Conversation

woorui
Copy link
Collaborator

@woorui woorui commented Aug 7, 2023

Description

Refactor AsyncHandler to interface:

// AsyncHandler represents the request-response mode (async).
// The AsyncHandler receives messages asynchronously in the Handle function, meaning it
// cannot guarantee the order of the messages.
type AsyncHandler interface {
	// Init initializes the handler.
	// The init function may return an error if initialization fails.
	Init(args ...string) error
	// Handle handles the observed messages.
	Handle(ctx serverless.Context)
}

add AsyncHandleFunc to make a function easy to implement AsyncHandler interface.

// AsyncHandleFunc handles the observed messages.
// AsyncHandleFunc implements the AsyncHandler interface and does nothing when the Init function is called.
type AsyncHandleFunc func(ctx serverless.Context)

StreamFunction add new function Init(args ...string) error for calling the init function of handler, It should be called after SetHandler and be called before Connect.

// StreamFunction defines serverless streaming functions.
type StreamFunction interface {
	// SetObserveDataTags set the data tag list that will be observed
	// Deprecated: use yomo.WithObserveDataTags instead
	SetObserveDataTags(tag ...uint32)
	// SetHandler set the handler function, which accept the raw bytes data and return the tag & response
	SetHandler(fn AsyncHandler) error
	// SetErrorHandler set the error handler function when server error occurs
	SetErrorHandler(fn func(err error))
	// SetPipeHandler set the pipe handler function
	SetPipeHandler(fn PipeHandler) error
	// Init initialize the stream function, It should be called after SetHandler and be called before Connect.
	Init(args ...string) error
	// Connect create a connection to the zipper
	Connect() error
	// Close will close the connection
	Close() error
}

@woorui woorui self-assigned this Aug 7, 2023
@vercel
Copy link

vercel bot commented Aug 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
yomo ⬜️ Ignored (Inspect) Visit Preview Aug 15, 2023 3:40am

Base automatically changed from feat/metadata to master August 8, 2023 01:18
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #572 (771730f) into master (d391c37) will increase coverage by 0.83%.
The diff coverage is 19.35%.

@@            Coverage Diff             @@
##           master     #572      +/-   ##
==========================================
+ Coverage   63.60%   64.44%   +0.83%     
==========================================
  Files          39       40       +1     
  Lines        2915     2936      +21     
==========================================
+ Hits         1854     1892      +38     
+ Misses        929      913      -16     
+ Partials      132      131       -1     
Files Changed Coverage Δ
handler_type.go 0.00% <0.00%> (ø)
sfn.go 19.27% <15.00%> (+0.56%) ⬆️
core/server.go 66.20% <100.00%> (+0.18%) ⬆️
source.go 67.60% <100.00%> (+9.85%) ⬆️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@woorui woorui closed this Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants