Skip to content

refactor(serialization): provide type registration facade in schema package - #468

Merged
shentongmartin merged 8 commits into
mainfrom
refactor/serialization
Sep 29, 2025
Merged

refactor(serialization): provide type registration facade in schema package#468
shentongmartin merged 8 commits into
mainfrom
refactor/serialization

Conversation

@shentongmartin

@shentongmartin shentongmartin commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

this PR centralized type registration to the schema package, hiding details such as Gob or eino's internal serialization mechanism.

New APIs:

// RegisterName registers the given type `T` with a specific name for both the generic
// serialization system and the gob serialization system. This is useful for maintaining
// backward compatibility with older data by explicitly mapping a type to a previously
// used name.
// It panics if the registration fails.
func RegisterName[T any](name string) {}

// Register registers the given type `T` with the gob serialization system and the
// generic serialization system. It automatically determines the type name based on
// its reflection data, including the package path for named types. This function
// should be used for new types where a custom name is not required.
// It panics if the registration fails.
func Register[T any]() {}

For each type that may need to be serialized either by graph or adk, call schema.Register or schema.RegisterName in the init() function within the go file that declares that type. e.g.:

type ChatModelAgentInterruptInfo struct {
	Info *compose.InterruptInfo
	Data []byte
}

func init() {
	schema.Register[*ChatModelAgentInterruptInfo]()
}

@github-actions

github-actions Bot commented Sep 23, 2025

Copy link
Copy Markdown

📊 Coverage Report:

File coverage threshold (20%) satisfied:	PASS
Package coverage threshold (30%) satisfied:	PASS
Total coverage threshold (83%) satisfied:	PASS
Total test coverage: 83.2% (6235/7497)

@shentongmartin
shentongmartin force-pushed the refactor/serialization branch 3 times, most recently from 5dde99b to 26050fc Compare September 26, 2025 01:52
…ackage

Change-Id: I0cb7e5831aa32e37929f5d71ee13ecb6f3088bba
Change-Id: I90001fe760da63025f229508c4d49656267efd3d
Change-Id: I74a980f76ef053449569e4f2e7633fb28351226f
…tibility

Change-Id: Ib6883037d81d5e4b0f4aade51ff6431e4feed3c8
Change-Id: I60c04002a0aece4204adf1e6709c32b6e86b375f
Change-Id: I2f9d0e2683b90eddbb202dc9b416bd08ed7d87b9
Comment thread adk/chatmodel.go
Comment thread adk/interrupt.go Outdated
Comment thread internal/serialization/serialization_test.go
Comment thread schema/serialization.go Outdated
Comment thread schema/serialization.go
Change-Id: I634ed2021f7bde12f83122253cbd272cc9550022
@meguminnnnnnnnn

Copy link
Copy Markdown
Contributor

覆盖率差一点

Change-Id: I734dc191f519e7e6b51e97cbaef4659974e72487
@shentongmartin
shentongmartin merged commit fd9337b into main Sep 29, 2025
13 checks passed
@shentongmartin
shentongmartin deleted the refactor/serialization branch September 29, 2025 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants