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

Entity state api #662

Merged
merged 13 commits into from
Mar 1, 2023
Merged

Entity state api #662

merged 13 commits into from
Mar 1, 2023

Conversation

johnshaughnessy
Copy link
Contributor

@johnshaughnessy johnshaughnessy commented Jan 20, 2023

Add Entities and SubEntities.

Each Entity is composed of:

  • A create_message, which tells clients how to spawn the entity (hierarchy) in the game world, and
  • Many SubEntities, which tell the client how to configure the components of spawned sub-entities.

Four Entity-related apis are added to the HubChannel:

name permission notes
list_entities none
save_entity_state pin_objects Fails (gracefully) if an Entity (for the given nid) already exists
update_entity_state pin_objects Fails (gracefully) if an Entity (for the given root_nid) does not already exist
delete_entity_state pin_objects Fails (gracefully) if an Entity (for the given nid) does not already exist

Clients refer to Entities (and SubEntities) via nids, which are shared, client-generated string IDs.

Clients only care about the embedded CreateMessages (of Entities) and UpdateMessages (of SubEntities), so EntityView returns this data exclusively.

Client changes: Hubs-Foundation/hubs#5904

@johnshaughnessy johnshaughnessy force-pushed the feature/message-store branch 2 times, most recently from 7467842 to 741a23e Compare January 23, 2023 03:33
@johnshaughnessy johnshaughnessy changed the base branch from master to upgrade-elixir January 29, 2023 06:06
@johnshaughnessy johnshaughnessy force-pushed the feature/message-store branch 2 times, most recently from bb4b8f0 to 96f686c Compare January 29, 2023 20:40
@johnshaughnessy johnshaughnessy changed the title WIP New way to save entity states Entity state api Jan 31, 2023
@johnshaughnessy johnshaughnessy marked this pull request as ready for review January 31, 2023 16:17
Base automatically changed from upgrade-elixir to master February 1, 2023 16:30
Copy link
Contributor

@bryanenders bryanenders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m having trouble following this schema design; let’s chat. This could also use some tests.

lib/ret_web/channels/hub_channel.ex Outdated Show resolved Hide resolved
lib/ret_web/channels/hub_channel.ex Outdated Show resolved Hide resolved
lib/ret_web/channels/hub_channel.ex Outdated Show resolved Hide resolved
lib/ret_web/channels/hub_channel.ex Outdated Show resolved Hide resolved
lib/ret_web/channels/hub_channel.ex Show resolved Hide resolved
lib/ret/entity_state/create_message.ex Outdated Show resolved Hide resolved
lib/ret/entity_state/update_message.ex Outdated Show resolved Hide resolved
@johnshaughnessy johnshaughnessy force-pushed the feature/message-store branch 2 times, most recently from 360bdf7 to f836e24 Compare February 10, 2023 06:13
lib/ret_web/channels/hub_channel.ex Outdated Show resolved Hide resolved
fn %{entity: entity} ->
Enum.map(updates, &SubEntity.for_bulk_insert(hub, entity, &1))
end
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m fairly certain this whole create_entity/2 function is achievable with a single Repo.insert/1 sans the Multi. Ecto.Changeset.cast_assoc/3 is the key. We can chat.

lib/ret_web/channels/hub_channel.ex Show resolved Hide resolved
lib/ret/entity_state/create_message.ex Outdated Show resolved Hide resolved
@bryanenders
Copy link
Contributor

This is looking really good! It’s almost there!

Copy link
Contributor

@bryanenders bryanenders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/ret_web/channels/entity_test.exs Outdated Show resolved Hide resolved
test/ret_web/channels/entity_test.exs Outdated Show resolved Hide resolved
@johnshaughnessy johnshaughnessy temporarily deployed to smoke March 1, 2023 00:59 — with GitHub Actions Inactive
@johnshaughnessy johnshaughnessy merged commit 07918f8 into master Mar 1, 2023
@johnshaughnessy johnshaughnessy deleted the feature/message-store branch March 1, 2023 01:02
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.

None yet

2 participants