-
Notifications
You must be signed in to change notification settings - Fork 147
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
feature: pagefind in public page #2992
Conversation
0541420
to
a4fff9c
Compare
server/src/bin/ingestion-worker.rs
Outdated
if dataset_config.PAGEFIND_ENABLED { | ||
let pagefind_worker_message = PagefindIndexWorkerMessage { | ||
dataset_id: payload.dataset_id, | ||
created_at: chrono::Utc::now().naive_utc(), | ||
attempt_number: 0, | ||
}; | ||
|
||
let serialized_message = | ||
serde_json::to_string(&pagefind_worker_message).map_err(|_| { | ||
ServiceError::InternalServerError( | ||
"Failed to serialize message".to_string(), | ||
) | ||
}); | ||
|
||
let maybe_redis = redis_pool | ||
.get() | ||
.await | ||
.map_err(|err| ServiceError::BadRequest(err.to_string())); | ||
|
||
let response: Result<(), ServiceError> = match (serialized_message.clone(), maybe_redis) { | ||
(Ok(message), Ok(mut redis_conn)) => { | ||
redis::cmd("lpush") | ||
.arg("pagefind-index-ingestion") | ||
.arg(&message) | ||
.query_async::<_, ()>(&mut *redis_conn) | ||
.await | ||
.map_err(|err| ServiceError::BadRequest(err.to_string())) | ||
.map(|_| ()) | ||
}, | ||
(Err(serial_error), Ok(_)) => { | ||
Err(ServiceError::InternalServerError(format!("couldn't get serialized message {:?}", serial_error))) | ||
} | ||
(Ok(_), Err(redis_error)) => { | ||
Err(ServiceError::InternalServerError(format!("couldn't get redis conn {:?}", redis_error))) | ||
} | ||
(Err(serial_error), Err(redis_error)) => { | ||
Err(ServiceError::InternalServerError(format!("couldn't get serialize message and couldn't redis conn {:?} {:?}", serial_error, redis_error))) | ||
} | ||
}; | ||
|
||
match response { | ||
Ok(_) => log::info!("Queue'd dataset for pagefind indexing"), | ||
Err(e) => log::error!("Failed to start pagefind indexing {:?}", e) | ||
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we auto trigger a full pagefind reingest, anytime a batch of chunks is updated, we will likely move this logic, if we get charged too much
434a445
to
adcb79e
Compare
server, easier to distribute and rebalance
adcb79e
to
d2f385e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Added a pagefind option onto public page settings.
This does require new env's mainly. We have an s3 bucket that we use internally, PM me for the ACCESS_KEY and SECRET_KEY. Afterwards, your index will be able to get uploaded into the bucket.