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

Migrate to scalable tag bucket data structure #9

Merged
merged 1 commit into from
Jan 24, 2023

Conversation

chungquantin
Copy link
Owner

What is Tag Bucket?

Tag bucket stores the configuration passed into the action handler. Therefore, more databases can be supported dynamically. Opens a chance for SQL storage integration.

  • Current tag allowed are: column_family which for databases with column families design. There can be tags like table for SQL table.
type TagKey = &'static str;
type TagValue = String;
type TagBucketInner = HashMap<TagKey, TagValue>;

#[derive(Clone, Default)]
pub struct TagBucket(TagBucketInner);

impl TagBucket {
	pub fn new(map: TagBucketInner) -> TagBucket {
		TagBucket(map)
	}

	pub fn get(&self, key: TagKey) -> Option<TagValue> {
		self.0.get(key).cloned()
	}

	pub fn unchecked_get(&self, key: TagKey) -> TagValue {
		self.0.get(key).unwrap().clone()
	}

	pub fn get_bytes(&self, key: TagKey) -> Option<Vec<u8>> {
		let wrapped_value = self.0.get(key).cloned();
		if let Some(v) = wrapped_value {
			return Some(v.as_bytes().to_vec());
		}
		None
	}
}

@chungquantin chungquantin merged commit e27e833 into master Jan 24, 2023
@chungquantin chungquantin deleted the feat/tag-bucket branch January 24, 2023 17:07
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.

1 participant